LangChain
Agent quickstart

LangChain

Decorate plain functions with @tool. Works with both AgentExecutor and LangGraph.

Example

from langchain_core.tools import tool
import httpx, os, uuid

API = "https://api.b2a.bluepillow.com/v1"
KEY = os.environ["B2A_API_KEY"]

@tool
def b2a_search_stays(destination_id: str, check_in: str, check_out: str, adults: int) -> dict:
    """Ranked discovery search for accommodations."""
    r = httpx.post(
        f"{API}/search/stays",
        headers={
            "Authorization": f"Bearer {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},
        },
        timeout=10.0,
    )
    r.raise_for_status()
    return r.json()

Bind via llm.bind_tools([b2a_search_stays, ...]) or pass to create_react_agent.