Skip to main content

postbridge-llamaindex

Drop-in PostBridge tools for LlamaIndex — send physical letters to US, France, UK, Canada, and Germany from any LlamaIndex agent.

Install

pip install postbridge-llamaindex
# Or from the monorepo:
pip install -e integrations/postbridge_llamaindex

Quickstart — FunctionAgent (function calling)

import asyncio
from llama_index.llms.openai import OpenAI
from llama_index.core.agent.workflow import FunctionAgent
from postbridge_llamaindex import postbridge_tools

agent = FunctionAgent(
    tools=postbridge_tools(),        # all 8 tools
    llm=OpenAI(model="gpt-4o-mini"),
    system_prompt="You are a postal assistant...",
)

response = asyncio.run(agent.run(
    "Send a letter to Marie Dupont at 15 Rue de Rivoli, 75001 Paris, France..."
))
print(response)

Quickstart — ReActAgent (works with any LLM)

from llama_index.core.agent import ReActAgent
from llama_index.llms.openai import OpenAI
from postbridge_llamaindex import postbridge_tools

agent = ReActAgent.from_tools(
    tools=postbridge_tools(),
    llm=OpenAI(model="gpt-4o-mini"),
    verbose=True,
)

response = agent.chat("Send a letter to Paris...")

Quickstart — Direct tool binding

from llama_index.llms.openai import OpenAI
from postbridge_llamaindex import postbridge_tools

llm = OpenAI(model="gpt-4o-mini")
result = llm.predict_and_call(
    tools=postbridge_tools(only=["quote_letter"]),
    user_msg="What would it cost to send a letter to 75001 Paris via fr_lettre_verte?",
)
print(result)

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

Filter the toolkit to match your agent's scope:

# Reporter agent — read-only
tools = postbridge_tools(only=["list_services", "quote_letter", "track_letter", "get_proof"])

# Dispatcher agent — send + track
tools = postbridge_tools(only=["send_letter", "track_letter"])

# Full negotiation flow
tools = postbridge_tools(only=["negotiate_pricing", "accept_offer", "send_letter"])

Authentication

Tools call https://api.postbridge.ai and read POSTBRIDGE_API_KEY from the environment. Three ways to get one:

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 LlamaIndex Agent"}'
export POSTBRIDGE_API_KEY=pb_live_...

2. Register with email: postbridge.ai/developers.html

3. Pay-per-request with x402 USDC: see postbridge.ai — no API key needed.

Async support

Every tool ships with both a sync and async path. LlamaIndex's modern agent flows (FunctionAgent, AgentWorkflow) use the async variant by default. The async wrapper runs the HTTP call in a worker thread so it doesn't block the event loop.

How it works

Tools are dynamically generated from PostBridge's canonical tools.json catalog — the same source that powers the OpenAI / Anthropic / Gemini / Mistral / CrewAI / LangChain adapters. Each LlamaIndex FunctionTool gets:

  • fn_schema — Pydantic model built from the tool's JSON Schema (includes enums, optionals, descriptions)
  • fn + async_fn — both routes delegate to the shared dispatcher.execute()

One source of truth, consistent validation across every agent framework PostBridge supports.

Design rules

The tools enforce PostBridge's server-side determinism:

  • 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 via webhook/API/email
  • Pricing confidentiality — internal pricing fields scrubbed from responses

Metadata

Release files for postbridge-llamaindex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for postbridge-llamaindex 0.1.0
File Size Uploaded
postbridge_llamaindex-0.1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for postbridge-llamaindex 0.1.0
File Interpreter ABI Platform
postbridge_llamaindex-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / postbridge_llamaindex-0.1.0.tar.gz

Download URL postbridge_llamaindex-0.1.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8dfce91ea8412321c335a9b851ecdd79a98db31d6aa469ee1dbf5a27d9bb5e29
BLAKE2b-256 checksum
How to use checksums
c9728ebeb7e67f35d4adf6133b53731277c15baf5e001ab7ea376371311111a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / postbridge_llamaindex-0.1.0-py3-none-any.whl

Download URL postbridge_llamaindex-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee08dca95db61320c8c899c6110e455594e5c308c880fa16df07f04473eb70e8
BLAKE2b-256 checksum
How to use checksums
4ebe238e0cb3455eebd75bf4cb47e28f0e5fe8ef3ee7afbc699e56a7181f970d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page