Skip to content
AGNT
All guides
Ecosystem workflowintermediate

Use AGNT venues as LangChain agent tools

Wrap AGNT's REST API as LangChain Tool objects for agent-based venue search and booking.

LangChain agents reason by calling tools. This guide shows you how to define AGNT's venue search, booking, and memory endpoints as LangChain Tool objects that any agent can invoke during its reasoning chain.

AGNT Developer Experience12 minverified 2026-04-12

Prerequisites

  • An AGNT developer API key.
  • Python 3.10+ with langchain and langchain-openai installed.
  • Basic familiarity with LangChain agents and tools.

What you're building

A LangChain agent with three custom tools: `search_venues` (semantic venue search), `get_venue_details` (full venue profile), and `create_booking` (book a table). The agent uses these tools during its reasoning to answer user questions about restaurants, bars, and cafes in Bali.

Step 1 — Define the search_venues tool

Create a LangChain `Tool` that calls AGNT's `/api/venues/search` endpoint:

from langchain.tools import Tool
import requests

def search_venues(query: str) -> str:
    resp = requests.get(
        "https://api.agntdot.com/api/venues/search",
        params={"q": query, "limit": 5},
        headers={"Authorization": f"Bearer {AGNT_API_KEY}"},
    )
    venues = resp.json()["results"]
    return "\n".join(f"- {v['name']} ({v['area']})" for v in venues)

search_tool = Tool(
    name="search_venues",
    description="Search for restaurants, bars, and cafes in Bali by intent or name.",
    func=search_venues,
)

Step 2 — Wire the tool into an agent

Use LangChain's `create_react_agent` to build an agent that has access to your AGNT tools:

from langchain_openai import ChatOpenAI
from langchain.agents import create_react_agent, AgentExecutor

llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(llm, [search_tool], prompt)
executor = AgentExecutor(agent=agent, tools=[search_tool])

result = executor.invoke({"input": "find sunset bars in Uluwatu"})
print(result["output"])

Step 3 — Add booking and memory tools

Follow the same pattern for `create_booking` (POST `/api/bookings`) and `read_user_memory` (GET `/api/memory`). Each tool wraps one AGNT REST endpoint with a clear description that the LLM uses to decide when to invoke it.

The key insight: LangChain's tool descriptions drive the agent's reasoning. Write descriptions that explain the tool's purpose, inputs, and outputs in plain English — the model will figure out when to call each tool based on the user's question.

Why this matters

LangChain is the most widely adopted agent framework. By wrapping AGNT's API as standard LangChain tools, you unlock the entire LangChain ecosystem — chains, memory, callbacks, tracing — while AGNT provides the real-world data layer. The same tools work in CrewAI, AutoGen, and any LangChain-compatible framework.

Next steps