Quickstart
From zero to a working agent in five minutes.
Requirements
Python 3.10+ · macOS, Linux, or Windows · an API key from Anthropic, OpenAI, or any LangChain-compatible provider.1. Install
pip install gantrygraph
# with browser and search extras
pip install 'gantrygraph[browser,search]'
playwright install chromium2. Set your API key
export ANTHROPIC_API_KEY="sk-ant-..."
# or
export OPENAI_API_KEY="sk-..."3. Your first agent
Create hello_agent.py:
from gantrygraph import GantryEngine
from langchain_anthropic import ChatAnthropic
agent = GantryEngine(
llm=ChatAnthropic(model="claude-sonnet-4-6"),
max_steps=20,
)
result = agent.run("What is the current working directory?")
print(result)4. Add a browser
from gantrygraph import GantryEngine
from gantrygraph.perception import WebPage
from gantrygraph.actions import BrowserTools
from langchain_anthropic import ChatAnthropic
web = WebPage(url="https://news.ycombinator.com", headless=True)
agent = GantryEngine(
llm=ChatAnthropic(model="claude-sonnet-4-6"),
perception=web,
tools=[BrowserTools(web_page=web)],
max_steps=20,
)
result = agent.run("Find the top 5 stories and return their titles and links.")
print(result)That's it
You have a working browser agent. From here, add tools, tighten security, and stream events to your UI.5. Stream events in real time
import asyncio
from gantrygraph import GantryEngine
from gantrygraph.perception import WebPage
from gantrygraph.actions import BrowserTools
from langchain_anthropic import ChatAnthropic
async def main():
web = WebPage(url="https://example.com", headless=True)
agent = GantryEngine(
llm=ChatAnthropic(model="claude-sonnet-4-6"),
perception=web,
tools=[BrowserTools(web_page=web)],
)
async for event in agent.astream_events("Find the pricing page"):
print(event.event_type, event.step, event.data)
asyncio.run(main())Next steps
- Read The agent loop to understand observe → think → act → review.
- Add guardrails before granting wider access — see Guardrails.
- Browse the full API Reference.