Integration · CrewAI
CrewAI.
CrewAI exposes tools to its agents via the @tool or BaseTool patterns. Wrap the Agent Cert REST API as a tool and your crew can certify any decision before returning it.
Define the tool
from crewai_tools import BaseTool
from pydantic import Field
import os, requests
from typing import List, Optional
API_BASE = os.environ["AGENT_CERT_API_BASE"]
API_KEY = os.environ["AGENT_CERT_API_KEY"]
class CertifyDecision(BaseTool):
name: str = "certify_decision"
description: str = (
"Certify an AI decision with Agent Cert. Returns a signed, anchored "
"Decision Receipt with a public verify URL. Call this for any "
"decision the crew makes that requires auditability."
)
def _run(
self,
agent_id: str,
user_intent: str,
agent_output: str,
tools_used: List[str],
retrieval_summary: Optional[str] = None,
) -> dict:
r = requests.post(
f"{API_BASE}/v1/receipts",
headers={"X-API-Key": API_KEY},
json={
"agent_id": agent_id,
"platform": "crewai",
"user_intent": user_intent,
"agent_output": agent_output,
"tools_used": tools_used,
"retrieval_summary": retrieval_summary,
},
)
r.raise_for_status()
return r.json()Add the tool to an agent
from crewai import Agent
reviewer = Agent(
role="Compliance Reviewer",
goal="Approve invoices under $5,000 from approved vendors only.",
backstory="You triple-check every approval against policy.",
tools=[CertifyDecision()],
verbose=True,
)Wire the tool into the agent's task
In your task description, explicitly instruct the agent to certify the outcome:
from crewai import Task
task = Task(
description=(
"Review the invoice for vendor {vendor} at amount {amount}. "
"Decide approve or deny. After deciding, call certify_decision "
"with the user_intent, your decision as agent_output, and the "
"list of tools you used. Include the resulting verify_url in "
"your final response."
),
expected_output="An approval decision plus a verify_url from Agent Cert.",
agent=reviewer,
)Multi-agent flow
For a crew with multiple agents (e.g. researcher → reviewer → writer), typically only the final agent calls certify_decision — that's the agent making the ultimate decision. Intermediate agents leave a trail you can reference in retrieval_summary.
Costs
- Each
certify_decisioncall: 3 Agent Cert credits. - CrewAI itself: no additional Agent Cert cost — the tool is just an HTTP call.
See also
- REST API reference
- Bind a policy instead of passing rules per call