CrewAI Integration
Build multi-agent finance teams with shared budgets and payment capabilities using CrewAI and Sardis.
Installation
pip install sardis-crewaiThe CrewAI integration provides pre-built agents, tasks, and tools optimized for multi-agent financial workflows.
Quick Start
create_sardis_tools()
Generate all Sardis tools for use with any CrewAI agent.
from crewai import Agent, Task, Crew
from sardis_crewai import create_sardis_tools
# Create Sardis tools
sardis_tools = create_sardis_tools(
api_key="sk_live_...",
agent_id="agent_abc123"
)
# Create a custom agent with payment capabilities
finance_agent = Agent(
role="Finance Manager",
goal="Manage company expenses efficiently",
backstory="Expert financial analyst with budget oversight",
tools=sardis_tools,
verbose=True
)
# Define a task
task = Task(
description="Pay $100 to AWS for cloud hosting",
agent=finance_agent,
expected_output="Payment confirmation with transaction ID"
)
# Execute
crew = Crew(agents=[finance_agent], tasks=[task])
result = crew.kickoff()
print(result)Pre-Built Agent Factories
Use specialized agent factories for common financial roles.
create_payment_agent()
Agent optimized for executing payments and managing transactions.
from sardis_crewai import create_payment_agent
payment_agent = create_payment_agent(
api_key="sk_live_...",
agent_id="agent_abc123",
llm="gpt-4" # Optional, defaults to gpt-4
)
# Pre-configured with:
# - Payment execution tool
# - Balance checking tool
# - Policy validation tool
# - Transaction history toolcreate_auditor_agent()
Read-only agent for financial oversight and compliance monitoring.
from sardis_crewai import create_auditor_agent
auditor = create_auditor_agent(
api_key="sk_live_...",
agent_id="agent_abc123"
)
# Pre-configured with:
# - Transaction history (read-only)
# - Balance checking (read-only)
# - Policy review (read-only)
# - No payment execution capabilitycreate_treasury_agent()
Agent focused on budget management and policy administration.
from sardis_crewai import create_treasury_agent
treasury = create_treasury_agent(
api_key="sk_live_...",
agent_id="agent_abc123"
)
# Pre-configured with:
# - Policy creation and updates
# - Budget allocation
# - Spending limit management
# - Balance monitoring across chainsPre-Built Task Templates
Common task templates for financial workflows.
from sardis_crewai import (
create_payment_task,
create_audit_task,
create_budget_review_task
)
# Payment execution task
pay_task = create_payment_task(
merchant="api.openai.com",
amount="50.00",
purpose="API credits",
agent=payment_agent
)
# Audit task
audit_task = create_audit_task(
start_date="2026-01-01",
end_date="2026-01-31",
agent=auditor,
context=[pay_task] # Runs after payment
)
# Budget review task
review_task = create_budget_review_task(
period="monthly",
agent=treasury
)Example: Multi-Agent Finance Team
Complete example of a collaborative finance team with shared budget.
from crewai import Crew, Process
from sardis_crewai import (
create_payment_agent,
create_auditor_agent,
create_treasury_agent,
create_payment_task,
create_audit_task
)
# Initialize agents
payment_agent = create_payment_agent(
api_key="sk_live_...",
agent_id="agent_payments"
)
auditor = create_auditor_agent(
api_key="sk_live_...",
agent_id="agent_auditor"
)
treasury = create_treasury_agent(
api_key="sk_live_...",
agent_id="agent_treasury"
)
# Define tasks
set_budget = Task(
description="""
Set a monthly budget policy:
- Max $500 per day for cloud infrastructure (AWS, GCP)
- Max $100 per day for AI APIs (OpenAI, Anthropic)
- Max $50 per transaction for development tools
""",
agent=treasury,
expected_output="Policy configuration summary"
)
make_payment = create_payment_task(
merchant="api.openai.com",
amount="75.00",
purpose="GPT-4 API credits for production",
agent=payment_agent
)
audit_transactions = create_audit_task(
start_date="2026-01-01",
end_date="2026-01-31",
agent=auditor,
context=[make_payment]
)
# Create crew with sequential process
finance_crew = Crew(
agents=[treasury, payment_agent, auditor],
tasks=[set_budget, make_payment, audit_transactions],
process=Process.sequential,
verbose=True
)
# Execute the workflow
result = finance_crew.kickoff()
print("\n=== Finance Team Results ===")
print(result)Hierarchical Teams
Use hierarchical process for manager-based approval workflows.
from crewai import Crew, Process, Agent
from sardis_crewai import create_payment_agent, create_sardis_tools
# Create payment agents for different departments
eng_payment_agent = create_payment_agent(
api_key="sk_live_...",
agent_id="agent_eng",
llm="gpt-4"
)
marketing_payment_agent = create_payment_agent(
api_key="sk_live_...",
agent_id="agent_marketing",
llm="gpt-4"
)
# Create CFO manager agent
cfo = Agent(
role="CFO and Finance Manager",
goal="Approve and oversee all company expenditures",
backstory="Senior executive with final approval authority",
tools=create_sardis_tools(
api_key="sk_live_...",
agent_id="agent_cfo"
),
verbose=True
)
# Hierarchical crew with CFO as manager
crew = Crew(
agents=[eng_payment_agent, marketing_payment_agent, cfo],
tasks=[eng_task, marketing_task],
process=Process.hierarchical,
manager_agent=cfo,
verbose=True
)
result = crew.kickoff()Shared Budget Pattern
Multiple agents can share the same wallet by using the same agent_id.
from sardis_crewai import create_payment_agent
# Shared agent_id = shared wallet and budget
SHARED_AGENT_ID = "agent_team_shared"
agent_1 = create_payment_agent(
api_key="sk_live_...",
agent_id=SHARED_AGENT_ID # Same ID
)
agent_2 = create_payment_agent(
api_key="sk_live_...",
agent_id=SHARED_AGENT_ID # Same ID
)
# Both agents:
# - Draw from the same wallet balance
# - Subject to the same spending policies
# - Transactions appear in shared historyBest Practices
- Use
create_treasury_agent()to set budgets before deploying payment agents - Include
create_auditor_agent()for compliance monitoring in production crews - Share
agent_idacross agents that should share a budget and policy - Use
Process.hierarchicalfor approval workflows with a manager agent - Set
verbose=Trueduring development to see inter-agent communication - Use the
contextparameter in tasks to create dependencies between agents
LangChain Integration
Add payment capabilities to your LangChain agents with native tool support. SardisToolkit provides 5 specialized tools for payment operations.
OpenAI Agents SDK Integration
Add payment capabilities to OpenAI Agents SDK agents with native function_tool support. Three tools with automatic schema generation.