Valta Docs
OpenAI Agents SDK Integration
Add Valta to any OpenAI agent in minutes. Each agent gets its own USDC wallet, programmable spending limits, and a kill switch you control from the dashboard.
Install
bash
pip install openai-agents requests
Get your API key
Sign up at valta.co/dashboard → Settings → API Keys → Create key.
Download the tool file
Save this as valta_tool.py in your project:
python
"""
Valta Wallet Tool for OpenAI Agents SDK
"""
import requests
from typing import Optional
from agents import function_tool
VALTA_BASE_URL = "https://www.valta.co"
def make_valta_tools(api_key: str):
headers = {"Authorization": f"Bearer {api_key}"}
@function_tool
def valta_check_balance(agent_id: str) -> str:
"""
Check how much USDC an AI agent has in its Valta wallet.
Use before spending to confirm funds are available.
agent_id: the Valta wallet ID or name (e.g. 'research-agent')
"""
r = requests.get(
f"{VALTA_BASE_URL}/api/v1/agents/{agent_id}/wallet",
headers=headers, timeout=10,
)
if r.status_code == 200:
data = r.json().get("wallet", {})
return (
f"Agent '{data.get('name', agent_id)}' wallet: "
f"{data.get('balance', 0)} USDC available | "
f"Status: {data.get('status', 'unknown')} | "
f"Daily limit: {data.get('limits', {}).get('daily', 'none')} USDC"
)
return f"Error fetching balance: {r.status_code} — {r.text}"
@function_tool
def valta_spend(agent_id: str, amount: float, description: str, category: str = "general") -> str:
"""
Request a spend from an agent's Valta wallet.
Approved or blocked based on the agent's spending policy.
agent_id: the Valta wallet ID or name
amount: amount in USDC to spend
description: what the spend is for
category: spend category (default: general)
"""
r = requests.post(
f"{VALTA_BASE_URL}/api/v1/agents/{agent_id}/wallet/spend",
json={"amount": amount, "description": description, "category": category},
headers=headers, timeout=10,
)
if r.status_code == 200:
data = r.json()
if data.get("approved"):
return f"Spend approved: {amount} USDC for '{description}'. New balance: {data.get('newBalance', 'N/A')} USDC"
return f"Spend blocked by policy: {data.get('reason', 'limit exceeded')}"
return f"Spend request failed: {r.status_code} — {r.text}"
@function_tool
def valta_create_wallet(name: str, daily_limit: Optional[float] = None, per_tx_limit: Optional[float] = None) -> str:
"""
Create a new named agent wallet on Valta.
name: a unique name for this agent's wallet (e.g. 'research-agent')
daily_limit: max USDC this agent can spend per day (optional)
per_tx_limit: max USDC per single transaction (optional)
"""
payload = {"name": name}
if daily_limit is not None:
payload["dailyLimit"] = daily_limit
if per_tx_limit is not None:
payload["perTxLimit"] = per_tx_limit
r = requests.post(
f"{VALTA_BASE_URL}/api/v1/wallets",
json=payload, headers=headers, timeout=10,
)
if r.status_code == 201:
data = r.json().get("wallet", {})
return f"Wallet created: '{data.get('name')}' | ID: {data.get('walletId')} | Daily limit: {data.get('limits', {}).get('daily', 'none')} USDC"
return f"Failed to create wallet: {r.status_code} — {r.text}"
@function_tool
def valta_transfer(from_agent_id: str, to_agent_id: str, amount: float, description: str = "") -> str:
"""
Transfer USDC between two agent wallets on Valta.
from_agent_id: wallet ID or name sending funds
to_agent_id: wallet ID or name receiving funds
amount: amount in USDC to transfer
"""
r = requests.post(
f"{VALTA_BASE_URL}/api/v1/wallet/transfer",
json={"fromAgentId": from_agent_id, "toAgentId": to_agent_id, "amount": amount, "description": description},
headers=headers, timeout=10,
)
if r.status_code == 200:
data = r.json()
return f"Transfer complete: {amount} USDC from {from_agent_id} → {to_agent_id}. TX: {data.get('txId', 'N/A')}"
return f"Transfer failed: {r.status_code} — {r.text}"
return [valta_check_balance, valta_spend, valta_create_wallet, valta_transfer]
Use it
python
from agents import Agent, Runner
from valta_tool import make_valta_tools
tools = make_valta_tools("sk_valta_your_api_key")
agent = Agent(
name="Financial Agent",
instructions="Always check balance before spending. Never exceed your daily limit.",
tools=tools,
)
result = Runner.run_sync(
agent,
"Check my wallet balance then spend 5 USDC on API credits if I have enough."
)
print(result.final_output)
Create a wallet for your agent
Before running, create a named wallet via the API:
bash
curl -X POST "https://www.valta.co/api/v1/wallets" \
-H "x-api-key: sk_valta_your_key" \
-H "Content-Type: application/json" \
-d '{"name": "my-openai-agent", "dailyLimit": 50, "perTxLimit": 10}'
Or let the agent create its own wallet on first run:
python
result = Runner.run_sync(agent, "Create a wallet named 'my-agent' with a $50 daily limit.")
Available tools
| Tool | What it does |
|---|---|
valta_check_balance | Check USDC balance and spending limits |
valta_spend | Request a spend — approved or blocked by policy |
valta_create_wallet | Create a new named wallet for an agent |
valta_transfer | Transfer USDC between agent wallets |
Spending policies
All spends are governed by limits you set at wallet creation or in the dashboard:
- Per-transaction cap — single spend ceiling
- Daily limit — total spend per day
- Monthly limit — total spend per month
- Kill switch — freeze any agent instantly from valta.co/dashboard
