CrewAI
Define B2A tools as CrewAI BaseTool subclasses.
Subclass BaseTool and assign to the relevant Agent. CrewAI’s role/task model
routes booking work to the tool automatically.
Example
from crewai.tools import BaseTool
import httpx, os, uuid
class B2ADecideTool(BaseTool):
name: str = "b2a_decide"
description: str = "Return one booking recommendation for a travel intent."
def _run(self, destination_id: str, check_in: str, check_out: str, adults: int) -> dict:
r = httpx.post(
"https://api.b2a.bluepillow.com/v1/decide",
headers={
"Authorization": f"Bearer {os.environ['B2A_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"location": {"type": "destination_id", "value": destination_id},
"dates": {"check_in": check_in, "check_out": check_out},
"guests": {"adults": adults},
"context": {"end_user_country": "US", "currency": "USD"},
},
timeout=10.0,
)
r.raise_for_status()
return r.json()
Attach via Agent(role=..., tools=[B2ADecideTool()]).