CrewAI Integration
View as MarkdownUse PostGrad as a tool in your CrewAI agents and crews.
Overview
PostGrad integrates with CrewAI as a custom tool, giving your agents access to structured business knowledge for research, strategy, and deal evaluation tasks.
Using the PostGrad SDK (Coming Soon)
Once the Python SDK is released, you can create a CrewAI tool:
from crewai.tools import tool
from postgrad import PostGrad
client = PostGrad(api_key="pg_live_YOUR_API_KEY")
@tool("Search Business Knowledge")
def search_knowledge(query: str) -> str:
"""Search PostGrad for structured business knowledge extracted from real meetings."""
results = client.search(query, limit=5)
return "\n\n".join(
f"**{e.title}** (confidence: {e.confidence})\n{e.content}"
for e in results.data
)Complete Crew Example
from crewai import Agent, Task, Crew
researcher = Agent(
role="Business Strategy Researcher",
goal="Find actionable business insights from real operator experience",
backstory="You are a senior analyst with access to a curated knowledge base of business strategy insights.",
tools=[search_knowledge],
)
task = Task(
description="Research pricing strategies for AI consulting services. Include confidence scores for each insight.",
expected_output="A report with 3-5 pricing strategies ranked by confidence.",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()
print(result)Using the REST API Directly
This approach works today without waiting for the SDK.
import requests
from crewai.tools import tool
API_KEY = "pg_live_YOUR_API_KEY"
@tool("Search Business Knowledge")
def search_knowledge(query: str) -> str:
"""Search PostGrad for structured business knowledge extracted from real meetings."""
response = requests.get(
"https://postgrad.io/api/v1/knowledge/search",
headers={
"Authorization": f"Bearer {API_KEY}",
# "all" fans out across every subscribed feed and merges results
# by relevance. Best default for a CrewAI tool because the agent
# doesn't know which feed to pick.
"X-PostGrad-Feed": "all",
},
params={"q": query, "limit": 5},
)
response.raise_for_status()
data = response.json()
return "\n\n".join(
f"**{e['title']}** (from {e.get('feed_name', 'unknown feed')}, confidence: {e['confidence']})\n{e['content']}"
for e in data["data"]
)Multi-Agent Crew
from crewai import Agent, Task, Crew
researcher = Agent(
role="Knowledge Researcher",
goal="Gather relevant business knowledge from PostGrad",
backstory="You research structured business insights from real operator experience.",
tools=[search_knowledge],
)
strategist = Agent(
role="Strategy Advisor",
goal="Synthesize research into actionable recommendations",
backstory="You turn raw research into clear strategic recommendations.",
)
research_task = Task(
description="Research what successful AI consulting firms charge and how they structure deals.",
expected_output="Raw findings with confidence scores from the knowledge base.",
agent=researcher,
)
strategy_task = Task(
description="Based on the research, recommend a pricing strategy for a new AI consulting practice.",
expected_output="A pricing strategy document with tiers, rationale, and risk factors.",
agent=strategist,
)
crew = Crew(agents=[researcher, strategist], tasks=[research_task, strategy_task])
result = crew.kickoff()
print(result)