Bitagent
Enable AI agents to discover each other, verify identity via DIDs, and pay for services using the Bitcoin Lightning Network and Nostr.
Ask AI about Bitagent
Powered by Claude Β· Grounded in docs
I know everything about Bitagent. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
BitAgent
Payment rails for AI agents β Bitcoin Lightning, built in.
BitAgent is an open-source framework for building AI agents that autonomously send and receive Bitcoin payments over the Lightning Network. Agents discover each other via Nostr, verify identity with DIDs, and coordinate multi-step workflows β all settled in real sats.
Why BitAgent?
Most AI agent frameworks treat money as an afterthought. BitAgent treats it as a first-class primitive.
Agent A Agent B (PolyglotAgent)
β β
βββ POST /polyglot/translate βββββββ>β
β<ββ { payment_request: "lnbc..." } ββ (no pay, no work)
β β
βββ pay Lightning invoice ββββββββββ>β LNbits
βββ POST /translate + payment_hash β>β
β<ββ { translated_text: "..." } ββββββ
- Agents charge sats for services β translation, transcription, data lookups, anything
- Agents pay other agents β chain services together, costs flow automatically
- No API keys or accounts β Lightning invoices are the auth layer
- Discoverable via Nostr β agents announce themselves; anyone can find and call them
Quick Start
Requirements: Python 3.11+, a LNbits wallet (free at legend.lnbits.com)
git clone https://github.com/intrinsicinvestment91/bitagent.git
cd bitagent
pip install -r requirements.txt
cp env.template .env
# edit .env: set LNBITS_URL and LNBITS_API_KEY
python main.py
The server starts on http://localhost:8000. Open /docs for the interactive API.
Translate text (100 sats):
# Step 1 β request service, get invoice
curl -X POST http://localhost:8000/polyglot/translate \
-H "Content-Type: application/json" \
-d '{"text": "Hello world", "target_language": "es"}'
# β {"payment_request": "lnbc...", "payment_hash": "abc123..."}
# Step 2 β pay the invoice with any Lightning wallet, then submit with payment_hash:
curl -X POST http://localhost:8000/polyglot/translate \
-H "Content-Type: application/json" \
-d '{"text": "Hello world", "target_language": "es", "payment_hash": "abc123..."}'
# β {"translated_text": "Hola mundo"}
What's Included
| Agent | Endpoint | Service | Price |
|---|---|---|---|
| PolyglotAgent | /polyglot/translate | Text translation (100+ languages) | 100 sats |
| PolyglotAgent | /polyglot/transcribe | Audio β text (Whisper) | 250 sats |
| CoordinatorAgent | /coordinator/translate_audio | Audio β transcribe β translate | 350 sats |
| PriceOracleAgent | /oracle/price/{coin} | Live crypto price (BTC, ETH, LTCβ¦) | 2 sats |
| WebFetchAgent | /fetch/url | Fetch & clean any public web page | 25 sats |
| SearchAgent | /search/query | Web search (Brave β SearXNG β DDG) | 10 sats |
| StreamfinderAgent | /a2a (JSON-RPC) | Streaming availability search | 100 sats |
| IdentityAgent | /a2a (JSON-RPC) + /.well-known/nostr.json | Paid NIP-05 registration + trust lookup | 1000 sats (register), 10-25 sats (queries) |
All agents implement the A2A JSON-RPC protocol β they can call each other without human involvement.
Use with Claude (MCP)
BitAgent ships an MCP server so Claude can call your agents as tools directly β no HTTP, no payment gate in the loop.
# Clone and install
git clone https://github.com/intrinsicinvestment91/bitagent.git
cd bitagent
pip install -r requirements.txt
# Add to Claude Code
claude mcp add bitagent -- python /path/to/bitagent/mcp_server.py
Or drop a .mcp.json in your project root:
{
"mcpServers": {
"bitagent": {
"type": "stdio",
"command": "python",
"args": ["/path/to/bitagent/mcp_server.py"]
}
}
}
Claude then has access to search, fetch_url, translate, get_price, and convert_sats as native tools. Each result includes a cost_sats field so you can track spending.
Architecture
src/
βββ agents/
β βββ polyglot_agent/ # Translation & transcription (FastAPI router)
β βββ coordinator_agent/ # Multi-agent orchestration
β βββ price_oracle_agent/ # Live crypto prices (CoinGecko β Binance fallback)
β βββ web_fetch_agent/ # Web page fetcher with SSRF protection
β βββ search_agent/ # Web search (Brave β SearXNG β DuckDuckGo fallback)
β βββ streamfinder/ # A2A reference implementation
βββ core/
β βββ agent.py # Base class: DID identity + wallet + security
β βββ agent_server.py # FastAPI wrapper with auto-generated endpoints
β βββ payment.py # Payment flow helpers
βββ security/ # JWT auth, AES-256 encryption, input validation
βββ identity/ # DID document management (did:key, did:nostr, did:bitcoin)
βββ network/ # Nostr discovery, DHT peer-to-peer
βββ wallets/ # LNbits client, Fedimint ecash wallet
mcp_server.py # MCP stdio server β exposes agents as Claude tools
Adding a new agent takes ~50 lines. Mount a FastAPI router, decorate your endpoint with @require_payment(min_sats=100), and you have a paid service.
IdentityAgent
IdentityAgent adds:
- paid
identity.register_nip05flow - machine-readable
identity.get_identityandidentity.get_trust_signal - dynamic NIP-05 resolution at
/.well-known/nostr.json?name=<handle>
Example trust lookup:
curl -X POST http://localhost:8000/a2a \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 11,
"method": "identity.get_trust_signal",
"params": { "pubkey": "npub1examplepubkey" }
}'
See IdentityAgent docs for full registration/payment flow, NIP-05 examples, and security warnings.
Use Cases
Paid translation API β instead of managing API keys and subscriptions, clients pay per request in sats. No account required.
Autonomous research pipeline β a coordinator agent calls a transcription agent, then a translation agent, then a summarization agent. Each hop is paid automatically from the coordinator's wallet.
Agent marketplace β agents announce services on Nostr. Other agents discover them by service type and price, pick the best option, and call them directly.
Metered AI services β wrap any ML model in an agent. Users pay per inference. No billing infrastructure needed.
Deployment
Cloud (Railway): Connect this repo on railway.app. Set LNBITS_URL and LNBITS_API_KEY as environment variables. Done.
Self-hosted (Start9): See docs/START9_DEPLOYMENT_GUIDE.md.
Docker:
docker-compose -f docker-compose.dev.yml up
Contributing
BitAgent is early. There's a lot of room to build.
See CONTRIBUTING.md for how to add new agents, payment backends, and discovery protocols.
Good first issues are labeled good first issue on GitHub.
License
MIT β use it, fork it, build on it.
