LangChain tools for BoltzPay — pay for API data with AI agents
Project description
langchain-boltzpay
LangChain tools for BoltzPay -- pay for API data with AI agents.
Install
pip install langchain-boltzpay
Prerequisites
- Node.js 20+ (nodejs.org) -- the CLI bridge calls
npx @boltzpay/cliunder the hood - Coinbase CDP keys (docs) -- only needed for
fetch(paid requests)
Quick Start
from langchain_openai import ChatOpenAI
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.prompts import ChatPromptTemplate
from langchain_boltzpay import (
BoltzPayFetchTool,
BoltzPayDiagnoseTool,
BoltzPayDiscoverTool,
)
tools = [BoltzPayDiscoverTool(), BoltzPayDiagnoseTool(), BoltzPayFetchTool()]
llm = ChatOpenAI(model="gpt-4o-mini")
prompt = ChatPromptTemplate.from_messages([
("system", "You are a researcher. Use BoltzPay to access paid APIs."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
])
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
result = executor.invoke({"input": "Diagnose the endpoint invy.bot/api"})
Tool Reference
| Tool | Name | Description | Credentials? |
|---|---|---|---|
BoltzPayFetchTool |
boltzpay_fetch |
Fetch data from a paid API, auto-pay with USDC | Yes |
BoltzPayQuoteTool |
boltzpay_quote |
Get price quote without paying | No |
BoltzPayDiscoverTool |
boltzpay_discover |
Browse available paid APIs | No |
BoltzPayBudgetTool |
boltzpay_budget |
Show remaining spending budget | No |
BoltzPayHistoryTool |
boltzpay_history |
Show payment history | No |
BoltzPayWalletTool |
boltzpay_wallet |
Show wallet and config info | No |
BoltzPayDiagnoseTool |
boltzpay_diagnose |
Full endpoint diagnostic (protocol, health, latency) | No |
No Credentials Needed
Most tools work without any credentials -- perfect for exploration:
from langchain_boltzpay import BoltzPayDiscoverTool, BoltzPayDiagnoseTool
# Discover available APIs
discover = BoltzPayDiscoverTool()
print(discover._run())
# Diagnose an endpoint (protocol, health, latency)
diagnose = BoltzPayDiagnoseTool()
print(diagnose._run(url="https://invy.bot/api"))
With Credentials
To actually fetch paid data, set Coinbase CDP environment variables:
export COINBASE_API_KEY_ID="your-key-id"
export COINBASE_API_KEY_SECRET="your-key-secret"
export COINBASE_WALLET_SECRET="your-wallet-secret"
from langchain_boltzpay import BoltzPayFetchTool
fetch = BoltzPayFetchTool()
result = fetch._run(url="https://invy.bot/api")
print(result) # Paid API response with payment receipt
Error Handling
All tools set handle_tool_error=True, so LangChain agents handle errors gracefully. You can also catch errors directly:
from langchain_boltzpay import BoltzPayFetchTool
from langchain_boltzpay.errors import (
BoltzPayBridgeError,
BoltzPayNodeNotFoundError,
BoltzPayTimeoutError,
)
try:
tool = BoltzPayFetchTool()
tool._run(url="https://example.com/api")
except BoltzPayNodeNotFoundError:
print("Install Node.js 20+ from https://nodejs.org")
except BoltzPayTimeoutError:
print("CLI command timed out (default: 30s)")
except BoltzPayBridgeError as e:
print(f"CLI error [{e.code}]: {e.message}")
Jupyter Notebook
See notebooks/getting-started.ipynb for a complete walkthrough: discover APIs, check prices, and create an agent.
MCP Alternative
If you're using CrewAI or another MCP-compatible framework, you can use the BoltzPay MCP server directly instead of this LangChain package:
npx @boltzpay/mcp
This exposes the same 7 tools via the Model Context Protocol.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_boltzpay-0.2.0.tar.gz.
File metadata
- Download URL: langchain_boltzpay-0.2.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6ead8c6b52172fcfb354d191e45c83d98eb34157de3c69ea96f5e6a9dc91c9e
|
|
| MD5 |
c8d345c2ff20fa5c54f9121c6f33cd0f
|
|
| BLAKE2b-256 |
6173445ac6d11c06e7cf209f0e73ebe084f922fe27d102afaa781392fd17a454
|
Provenance
The following attestation bundles were made for langchain_boltzpay-0.2.0.tar.gz:
Publisher:
release.yml on leventilo/boltzpay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_boltzpay-0.2.0.tar.gz -
Subject digest:
b6ead8c6b52172fcfb354d191e45c83d98eb34157de3c69ea96f5e6a9dc91c9e - Sigstore transparency entry: 1075534733
- Sigstore integration time:
-
Permalink:
leventilo/boltzpay@11883e246733a26dc752e6b11a4e68872d92a778 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/leventilo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@11883e246733a26dc752e6b11a4e68872d92a778 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file langchain_boltzpay-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langchain_boltzpay-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8fd69b1f3496fcd71a8a81223f1b725e673fd5d0f4f3e41c4468f6df83311b4
|
|
| MD5 |
e212671a883a756453d85d6b161b780f
|
|
| BLAKE2b-256 |
32e6ae212e5795fbf2f416c37238e87628268a651a45fce30804b8a4e376ef1c
|
Provenance
The following attestation bundles were made for langchain_boltzpay-0.2.0-py3-none-any.whl:
Publisher:
release.yml on leventilo/boltzpay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_boltzpay-0.2.0-py3-none-any.whl -
Subject digest:
e8fd69b1f3496fcd71a8a81223f1b725e673fd5d0f4f3e41c4468f6df83311b4 - Sigstore transparency entry: 1075534790
- Sigstore integration time:
-
Permalink:
leventilo/boltzpay@11883e246733a26dc752e6b11a4e68872d92a778 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/leventilo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@11883e246733a26dc752e6b11a4e68872d92a778 -
Trigger Event:
workflow_dispatch
-
Statement type: