Skip to main content

LangChain integration for Agent Toolbox API — search, extract, screenshot, weather, finance, email validation, and translation tools for AI agents

Project description

🧰 langchain-agent-toolbox

PyPI version License: MIT

LangChain integration for Agent Toolbox API — 7 tools giving your LangChain agents real-world superpowers.

Tool Endpoint Description
AgentToolboxSearchTool /v1/search Web search via DuckDuckGo
AgentToolboxExtractTool /v1/extract Extract content from any URL
AgentToolboxScreenshotTool /v1/screenshot Capture web page screenshots
AgentToolboxWeatherTool /v1/weather Current weather & forecasts
AgentToolboxFinanceTool /v1/finance Stock quotes & exchange rates
AgentToolboxEmailValidatorTool /v1/validate-email Email validation (MX + SMTP + disposable)
AgentToolboxTranslateTool /v1/translate Translation with auto-detect & glossary

Installation

pip install langchain-agent-toolbox

Quick Start

Get an API Key

curl -X POST https://api.sendtoclaw.com/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com"}'

Set Environment Variable

export AGENT_TOOLBOX_API_KEY="atb_your_key_here"

Use with LangChain

from langchain_agent_toolbox import AgentToolboxSearchTool, AgentToolboxWeatherTool

# Initialize tools
search = AgentToolboxSearchTool()
weather = AgentToolboxWeatherTool()

# Use directly
results = search.invoke({"query": "latest AI news", "count": 3})
print(results)

forecast = weather.invoke({"location": "Tokyo"})
print(forecast)

Use with a LangChain Agent

from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
from langchain_agent_toolbox import (
    AgentToolboxSearchTool,
    AgentToolboxExtractTool,
    AgentToolboxWeatherTool,
    AgentToolboxTranslateTool,
)

# Initialize tools
tools = [
    AgentToolboxSearchTool(),
    AgentToolboxExtractTool(),
    AgentToolboxWeatherTool(),
    AgentToolboxTranslateTool(),
]

# Create agent
llm = ChatOpenAI(model="gpt-4o")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant with access to web tools."),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])

agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

# Run
result = executor.invoke({
    "input": "What's the weather in Paris? Also search for top restaurants there."
})
print(result["output"])

Translation with Glossary

from langchain_agent_toolbox import AgentToolboxTranslateTool

translate = AgentToolboxTranslateTool()

# Simple translation
result = translate.invoke({
    "text": "Hello, how are you?",
    "target": "zh",
})
print(result)  # 你好,你好吗?

# With glossary (preserve technical terms)
result = translate.invoke({
    "text": "The API endpoint returns JSON data.",
    "target": "zh",
    "glossary": {"API": "API", "JSON": "JSON", "endpoint": "端点"},
})
print(result)  # API 端点 返回 JSON 数据。

Email Validation

from langchain_agent_toolbox import AgentToolboxEmailValidatorTool

validator = AgentToolboxEmailValidatorTool()

result = validator.invoke({"email": "test@gmail.com"})
print(result)
# {
#   "email": "test@gmail.com",
#   "valid_syntax": true,
#   "mx_found": true,
#   "is_disposable": false,
#   "verdict": "deliverable",
#   "score": 0.95
# }

Finance: Stocks & Exchange Rates

from langchain_agent_toolbox import AgentToolboxFinanceTool

finance = AgentToolboxFinanceTool()

# Stock quote
quote = finance.invoke({"symbol": "AAPL"})
print(quote)

# Currency exchange
rate = finance.invoke({
    "from_currency": "USD",
    "to_currency": "EUR",
    "amount": 100,
    "type": "exchange",
})
print(rate)

Configuration

API Key

Set via environment variable (recommended):

export AGENT_TOOLBOX_API_KEY="atb_your_key_here"

Or pass directly:

tool = AgentToolboxSearchTool(api_key="atb_your_key_here")

Custom Base URL

For self-hosted instances:

tool = AgentToolboxSearchTool(
    api_key="your-key",
    base_url="http://localhost:3100",
)

Or via environment variable:

export AGENT_TOOLBOX_BASE_URL="http://localhost:3100"

Async Support

All tools support async out of the box:

import asyncio
from langchain_agent_toolbox import AgentToolboxSearchTool

async def main():
    search = AgentToolboxSearchTool()
    result = await search.ainvoke({"query": "async python", "count": 3})
    print(result)

asyncio.run(main())

API Reference

All tools accept these common parameters:

Parameter Type Default Description
api_key str $AGENT_TOOLBOX_API_KEY API key for authentication
base_url str https://api.sendtoclaw.com API base URL

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_agent_toolbox-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_agent_toolbox-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file langchain_agent_toolbox-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_agent_toolbox-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for langchain_agent_toolbox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0bed4fd56706c23dae21d11e2d87332c23bb21e2b06ea81e5d181ecaa2fa84d4
MD5 61cdac7c293d0c2074b8c3d0f0bb9f66
BLAKE2b-256 4b5cdffd25c33f36d73031995ebd1a0c792f66e66152f24f31bc105556599a97

See more details on using hashes here.

File details

Details for the file langchain_agent_toolbox-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_agent_toolbox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 619f6e11f5252225aaaedad32823bed6f87bd25066d57b0986aea37c3886cbd9
MD5 ec9483657c5015c94d800011dc7e50e8
BLAKE2b-256 6bb9eb840d30e31a1861dc8b6e5f46af358942a4a043b939629810280ccb8c77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page