Skip to main content

Installation

pip install zespan crewai

Usage

Wrap your Crew instance with wrap_crew before calling kickoff. Both sync and async kickoff are supported.
from crewai import Agent, Task, Crew
from zespan.integrations.crewai_handler import wrap_crew
import zespan

zespan.init(api_key="zsp_your_api_key_here")

researcher = Agent(
    role="Researcher",
    goal="Research the topic thoroughly",
    backstory="Expert researcher with broad knowledge",
    llm="gpt-4o",
)

task = Task(
    description="Research the impact of LLMs on software development",
    expected_output="A detailed summary",
    agent=researcher,
)

crew = Crew(agents=[researcher], tasks=[task])
crew = wrap_crew(crew)

result = crew.kickoff(inputs={"topic": "LLMs in software development"})
print(result.raw)

Async usage

import asyncio

crew = wrap_crew(crew)
result = asyncio.run(crew.kickoff_async(inputs={"topic": "AI agents"}))

With guardrails

Pass guardrails=True to run pre/post content checks on crew inputs and outputs.
from zespan.integrations.crewai_handler import wrap_crew
from zespan import GuardrailBlockedError

crew = wrap_crew(crew, guardrails=True)

try:
    result = crew.kickoff(inputs={"topic": "..."})
except GuardrailBlockedError as e:
    print(f"Blocked at {e.phase}:", e.results)
For fine-grained control:
crew = wrap_crew(crew, guardrails={
    "pre": True,
    "post": True,
    "fail_closed": False,
})