Guides
Add Payments to Your AutoGen Agents
Integrate Wallgent financial tools into Microsoft AutoGen multi-agent conversations.
The Wallgent Python SDK ships in Phase 4. This guide shows the planned API so you can plan your integration today. See the REST fallback section below to get started now.
Prerequisites
- A Wallgent account and API key (get one here)
- Python 3.9+
1. Install
pip install wallgent autogen-agentchat autogen-ext[openai]2. Register Wallgent Functions
AutoGen agents use registered functions as callable tools during conversations:
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from wallgent import Wallgent
wg = Wallgent(api_key="wg_test_your_key_here")
async def check_balance(wallet_id: str) -> str:
"""Check the available balance of a Wallgent wallet."""
balance = await wg.wallets.async_get_balance(wallet_id)
return f"Available: ${balance.available}, Pending: ${balance.pending}"
async def send_payment(from_wallet: str, to_wallet: str, amount: str, description: str) -> str:
"""Send a payment between two Wallgent wallets."""
txn = await wg.payments.async_send(
from_wallet=from_wallet,
to_wallet=to_wallet,
amount=amount,
description=description,
)
return f"Payment {txn.id} — status: {txn.state}"3. Create an Agent
model = OpenAIChatCompletionClient(model="gpt-4o")
finance_agent = AssistantAgent(
name="FinanceAgent",
model_client=model,
tools=[check_balance, send_payment],
system_message="You are a financial agent. Use the available tools to manage wallets and payments.",
)4. Complete Example
import asyncio
from autogen_agentchat.ui import Console
from autogen_core import CancellationToken
async def main():
response = await finance_agent.run(
task="Check the balance of wal_ops, then send $25 to wal_vendor for the monthly subscription.",
cancellation_token=CancellationToken(),
)
await Console(response.messages)
asyncio.run(main())The agent will:
- Call
check_balance(wallet_id="wal_ops") - Call
send_payment(from_wallet="wal_ops", to_wallet="wal_vendor", amount="25.00", description="monthly subscription") - Return a natural language summary of both operations
REST Fallback
You can use Wallgent with AutoGen today by wrapping REST API calls:
import requests
API_KEY = "wg_test_your_key_here"
BASE = "https://api.wallgent.com"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
async def check_balance(wallet_id: str) -> str:
"""Check the available balance of a Wallgent wallet."""
resp = requests.get(f"{BASE}/v1/wallets/{wallet_id}/balance", headers=HEADERS)
data = resp.json()
return f"Available: ${data['available']}, Pending: ${data['pending']}"
async def send_payment(from_wallet: str, to_wallet: str, amount: str, description: str) -> str:
"""Send a payment between two Wallgent wallets."""
resp = requests.post(
f"{BASE}/v1/payments",
headers=HEADERS,
json={"from": from_wallet, "to": to_wallet, "amount": amount, "description": description},
)
data = resp.json()
return f"Payment {data['id']} — status: {data['state']}"Next Steps
- Explore spending policies to control agent budgets
- Add webhooks for event-driven workflows
- See the full REST API Reference for all available endpoints