postbridge-langchain
Drop-in PostBridge tools for LangChain and LangGraph — send physical letters to US, France, UK, Canada, and Germany from any LangChain agent, chain, or LangGraph node.
Install
# Core — tools + args validation only
pip install postbridge-langchain
# With AgentExecutor + OpenAI chat support
pip install "postbridge-langchain[agents]"
# With LangGraph
pip install "postbridge-langchain[langgraph]"
Quickstart — llm.bind_tools()
from langchain_openai import ChatOpenAI
from postbridge_langchain import postbridge_tools
llm = ChatOpenAI(model="gpt-4o-mini")
tools = postbridge_tools() # all 8 tools
llm_with_tools = llm.bind_tools(tools)
response = llm_with_tools.invoke("Send a letter to Paris saying hello")
# response.tool_calls → [{"name": "send_letter", "args": {...}}, ...]
Quickstart — LangChain 1.x create_agent
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from postbridge_langchain import postbridge_tools
agent = create_agent(
model=ChatOpenAI(model="gpt-4o-mini"),
tools=postbridge_tools(),
system_prompt="You are a postal assistant. Use tools to send letters.",
)
result = agent.invoke({"messages": [("human", "Send a letter to Paris saying hello")]})
print(result["messages"][-1].content)
Quickstart — LangChain 0.3.x (AgentExecutor, legacy)
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from postbridge_langchain import postbridge_tools
llm = ChatOpenAI(model="gpt-4o-mini")
tools = postbridge_tools()
prompt = ChatPromptTemplate.from_messages([
("system", "You are a postal assistant..."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
])
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
result = executor.invoke({"input": "Send a letter to Paris..."})
Quickstart — LangGraph
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from postbridge_langchain import postbridge_tools
llm = ChatOpenAI(model="gpt-4o-mini")
graph = create_react_agent(llm, tools=postbridge_tools())
result = graph.invoke({"messages": [("human", "Send a letter to Paris saying hello")]})
Tools available
| Tool | HTTP | Purpose |
|---|---|---|
list_services |
GET /api/services/{country} |
Discover services per country |
quote_letter |
POST /api/quote |
Price a letter |
send_letter |
POST /api/send |
Mail it |
track_letter |
GET /api/track/{letter_id} |
Live status |
get_proof |
GET /api/proof/{letter_id} |
Signed PostalProof VC |
get_balance |
GET /api/balance |
Wallet + ledger |
negotiate_pricing |
POST /api/anp/offer |
ANP tiered offer |
accept_offer |
POST /api/anp/accept |
Lock in tier |
Subset selection
# Read-only agent
tools = postbridge_tools(only=["list_services", "quote_letter", "track_letter", "get_proof"])
# Send-only dispatcher
tools = postbridge_tools(only=["send_letter", "track_letter"])
# Full ANP flow
tools = postbridge_tools(only=["negotiate_pricing", "accept_offer", "send_letter"])
Async support
Every tool implements both _run (sync) and _arun (async), so LangGraph's async nodes and LangChain's ainvoke work out of the box:
result = await llm_with_tools.ainvoke("Quote a letter to Berlin")
Authentication
Tools call https://api.postbridge.ai and read POSTBRIDGE_API_KEY from the environment. Three ways to get a key:
1. Auto-provision (no signup):
curl -X POST https://api.postbridge.ai/auth/agent \
-H 'Content-Type: application/json' \
-d '{"agent_id": "my-agent", "agent_name": "My LangChain Agent"}'
2. Register with email: postbridge.ai/developers.html
3. Pay-per-request with x402 USDC (no API key needed): see postbridge.ai.
How it works
Every tool is a langchain_core.tools.BaseTool subclass generated from the shared tools.json catalog that also powers PostBridge's OpenAI / Anthropic / Gemini / Mistral adapters. JSON Schema → Pydantic args_schema conversion catches bad inputs before they hit the API.
Tool execution delegates to the shared dispatcher.execute() — one HTTP path for all provider integrations, with path-param resolution, auth injection, and error surfacing.
Design rules (enforced by the API)
- Rate-table pricing — no LLM-estimated prices
- API-validated addresses — no LLM-composed addresses
- Recipient-country routing — postal service matches the destination
- Digital-only proof — certified-mail receipts are webhook/API/email
- Pricing confidentiality — internal pricing fields scrubbed from every response
Related
- Main API docs: postbridge.ai/developers.html
- Agent metadata: postbridge.ai/.well-known/agent.json
- Source of truth catalog:
integrations/schemas/tools.json - Sister packages:
postbridge-crewai(CrewAI), adapters for OpenAI / Anthropic / Gemini / Mistral - Example agent:
examples/langchain_sendletter.py
Metadata
Release files for postbridge-langchain 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| postbridge_langchain-0.1.0.tar.gz | 5.2 kB | Without provenance | Details for postbridge_langchain-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| postbridge_langchain-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for postbridge_langchain-0.1.0-py3-none-any.whl |
Total release size: 10.9 kB
Release files / postbridge_langchain-0.1.0.tar.gz
| Download URL | postbridge_langchain-0.1.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dcfd6929bb91a930bf57e523fcd7e02209c1b24adf71ae8adf45030b88f8b361
|
|
BLAKE2b-256 checksum How to use checksums |
6cb40776c8e77c9f99b3480efebf5a1a424b4e44dc59c27194b5adfa784549b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / postbridge_langchain-0.1.0-py3-none-any.whl
| Download URL | postbridge_langchain-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27e816298efc7fe28c7b713286b44e323877616e790a10670a82f4fdb411ab78
|
|
BLAKE2b-256 checksum How to use checksums |
5d951beb4c7bc619c3f26f8be6c3f4ac3306b55a8f1549047e27bd1327e7df96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Security for postbridge-langchain 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.