LangChain + Arch Tools
Use 64 production API tools inside your LangChain agents. Web scraping, AI generation, crypto data, image generation, email, and more — all as LangChain tools.
Contents
1. Overview
Arch Tools provides 64 production-ready API tools accessible via a single API key. Each tool is a simple POST endpoint at https://archtools.dev/v1/tools/{tool-name}. This makes them trivial to wrap as LangChain tools.
2. Installation
pip install langchain langchain-openai requests
Get your API key at archtools.dev/signup — 100 free credits included.
3. Basic Usage — Custom Tool
Wrap any Arch Tools endpoint as a LangChain Tool:
import requests
from langchain.tools import Tool
ARCH_API_KEY = "arch_your_key_here"
BASE_URL = "https://archtools.dev/v1/tools"
def arch_web_scrape(url: str) -> str:
"""Scrape a webpage and return its text content."""
resp = requests.post(
f"{BASE_URL}/web-scrape",
headers={"x-api-key": ARCH_API_KEY},
json={"url": url, "format": "markdown"}
)
data = resp.json()
return data.get("text", data.get("error", "Failed"))
web_scrape_tool = Tool(
name="web_scrape",
func=arch_web_scrape,
description="Scrape a webpage URL and return its content as markdown text."
)
4. Full Toolkit — All 64 Tools
Dynamically create LangChain tools from the Arch Tools discovery endpoint:
import requests
from langchain.tools import StructuredTool
from pydantic import BaseModel, Field
from typing import Optional
ARCH_API_KEY = "arch_your_key_here"
BASE = "https://archtools.dev"
def get_arch_tools():
"""Fetch all available tools and create LangChain wrappers."""
discovery = requests.get(f"{BASE}/v1/tools",
headers={"x-api-key": ARCH_API_KEY}).json()
tools = []
for t in discovery.get("tools", []):
tool_name = t["name"]
tool_desc = t.get("description", tool_name)
credits = t.get("credits", 5)
def make_caller(name):
def call_tool(**kwargs) -> str:
resp = requests.post(
f"{BASE}/v1/tools/{name}",
headers={"x-api-key": ARCH_API_KEY},
json=kwargs
)
return str(resp.json())
return call_tool
# Create a generic input model
class ToolInput(BaseModel):
input_json: str = Field(
description=f"JSON string of parameters for {tool_name}. {tool_desc}"
)
tools.append(StructuredTool(
name=tool_name.replace("-", "_"),
func=make_caller(tool_name),
description=f"{tool_desc} (costs {credits} credits)",
))
return tools
# Usage
arch_tools = get_arch_tools()
print(f"Loaded {len(arch_tools)} Arch Tools for LangChain")
5. Agent Example
Create a LangChain agent that can research topics, scrape websites, and generate summaries:
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
# Define specific tools for a focused agent
def arch_call(tool_name: str, **kwargs) -> dict:
resp = requests.post(
f"https://archtools.dev/v1/tools/{tool_name}",
headers={"x-api-key": ARCH_API_KEY},
json=kwargs
)
return resp.json()
tools = [
Tool(name="web_search", func=lambda q: str(arch_call("search-web", query=q)),
description="Search the web for information. Input: search query string."),
Tool(name="web_scrape", func=lambda u: str(arch_call("web-scrape", url=u)),
description="Scrape a webpage. Input: URL string."),
Tool(name="summarize", func=lambda t: str(arch_call("summarize", text=t, style="executive")),
description="Summarize text. Input: text string to summarize."),
Tool(name="sentiment", func=lambda t: str(arch_call("sentiment-analysis", text=t)),
description="Analyze sentiment. Input: text string."),
Tool(name="crypto_price", func=lambda s: str(arch_call("crypto-price", symbol=s)),
description="Get crypto price. Input: coin id like 'bitcoin' or 'ethereum'."),
]
# Create agent
llm = ChatOpenAI(model="gpt-4o", temperature=0)
prompt = ChatPromptTemplate.from_messages([
("system", "You are a research agent with access to web tools, crypto data, and text analysis. Use tools to answer questions accurately."),
("human", "{input}"),
MessagesPlaceholder("agent_scratchpad"),
])
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Run it
result = executor.invoke({"input": "What is the current Bitcoin price and market sentiment?"})
print(result["output"])
6. x402 Payment Integration
When credits run out, your LangChain agent can automatically pay per-call with USDC via the x402 protocol. The agent receives a 402 response with payment details and can construct a USDC payment to continue:
# When you get a 402, the response includes payment details:
# {
# "x402Version": 1,
# "accepts": [{"scheme": "exact", "network": "eip155:8453", ...}],
# "error": "PAYMENT-REQUIRED"
# }
#
# Your agent can use a crypto wallet SDK to sign and pay:
# 1. Parse the 402 response
# 2. Sign a USDC transfer matching the amount
# 3. Retry with X-Payment header containing the signed payment
#
# See: https://archtools.dev/x402-guide for full details
X-Credits-Remaining response header to track your balance. When it drops below 20, the X-Upgrade-URL header appears with a link to buy more credits.
7. Tips & Best Practices
- Credit awareness: Check
X-Credits-Remainingheaders to avoid unexpected 402 responses. - Error handling: Always check
resp.json()["ok"]before accessing data. - Rate limits: Free tier: 10 req/min. Pro: 60 req/min. Business: 300 req/min.
- BYOK: Pass your own API keys via headers (e.g.,
x-anthropic-key) for zero credit cost on AI tools. - Batch wisely: Chain tools in sequence — scrape → summarize → sentiment — for powerful analysis pipelines.
- MCP alternative: For Claude-native agents, consider the MCP integration instead.
100 free credits · No credit card required