{"id":18928850,"url":"https://github.com/lightninglabs/langchainbitcoin","last_synced_at":"2025-07-22T23:03:19.917Z","repository":{"id":171157573,"uuid":"642203594","full_name":"lightninglabs/LangChainBitcoin","owner":"lightninglabs","description":"AI tools for giving LangChain agents access to Bitcoin and the ability to traverse L402 APIs","archived":false,"fork":false,"pushed_at":"2024-07-03T00:51:20.000Z","size":52777,"stargazers_count":138,"open_issues_count":2,"forks_count":18,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-07-08T07:13:23.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lightninglabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-18T03:42:09.000Z","updated_at":"2025-05-15T17:20:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"916dad75-5f3f-4e04-821d-19ee25192142","html_url":"https://github.com/lightninglabs/LangChainBitcoin","commit_stats":null,"previous_names":["roasbeef/langchainl402","lightninglabs/langchainbitcoin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lightninglabs/LangChainBitcoin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightninglabs%2FLangChainBitcoin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightninglabs%2FLangChainBitcoin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightninglabs%2FLangChainBitcoin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightninglabs%2FLangChainBitcoin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lightninglabs","download_url":"https://codeload.github.com/lightninglabs/LangChainBitcoin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightninglabs%2FLangChainBitcoin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266586905,"owners_count":23952205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T11:28:25.371Z","updated_at":"2025-07-22T23:03:19.894Z","avatar_url":"https://github.com/lightninglabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LangChainBitcoin\n\n`LangChainBitcoin` is a suite of tools that enables `langchain` agents to\ndirectly interact with Bitcoin and also the Lightning Network. This package has\ntwo main features:\n  \n  * **LLM Agent BitcoinTools**: Using the newly available Open AP GPT-3/4\n    function calls and the built in set of abstractions for tools in\n    `langchain`, users can create agents that are capaable of holding Bitcoin\n    balance (on-chain and on LN), sending/receiving Bitcoin on LN, and also\n    generally interacting with a Lightning node (lnd).\n\n  * **L402 HTTP API Traversal**: LangChainL402 is a Python project that enables\n    users of the `requests` package to easily navigate APIs that require\n    [L402](https://docs.lightning.engineering/the-lightning-network/l402) based\n    authentication. This project also includes a LangChain APIChain compatible\n    wrapper that enables LangChain agents to interact with APIs that require\n    L402 for payment or authentication. This enables agents to access\n    real-world resources behind a Lightning metered API.\n\n\n## Features\n- Provides a wrapper around `requests` library to handle LSATs and Lightning\n  payments.\n\n- Easily integrates with APIs requiring L402-based authentication.\n\n- Designed to operate seamlessly with LND (Lightning Network Daemon).\n\n- Enables LangChain Agents traverse APIs that require L402 authentication\n  within an API Chain.\n\n- Generic set of Bitcoin tools giving agents the ability to hold and use the\n  Internet's native currency.\n\n\n\n## Installation\n\nTo install the LangChainL402 project, you can clone the repository directly\nfrom GitHub:\n\n```bash\ngit clone https://github.com/lightninglabs/LangChainBitcoin.git\ncd LangChainBitcoin\n```\n\nPlease ensure you have all the necessary Python dependencies installed. You can\ninstall them using pip:\n```\npip install -r requirements.txt\n```\n\n## Usage\n\n### LLM Agent Bitcoin Tools\n\nCheck out the contained Jupyter notebook for an interactive example you can\nrun/remix: [LLM Bitcoin Tools](llm_bitcoin_tools.ipynb).\n\n### L402 API Traversal\n\nCheck out the contained Jupyter notebook for an interactive example you can\nrun/remix: [LangChain402](langchain_L402_agent.ipynb).\n\nThis project provides classes to handle Lightning payments (e.g., `LndNode`,\n`LightningNode`) and to manage HTTP requests with L402-based authentication\n(`RequestsL402Wrapper`, `ResponseTextWrapper`).\n\nFirst, initialize the `LndNode` with your Lightning node's details. Then, you\ncan use the modified `L402APIChain` wrapper around the normal `APIChain` class\nto instantiate an L402-aware API Chain. If the server responds with a 402\nPayment Required status code, the library will automatically handle the payment\nand retry the request.\n\nHere is a basic example:\n```python\nimport requests\n\nfrom lightning import LndNode\n\nfrom l402_api_chain import L402APIChain\nfrom langchain_openai import OpenAI\n\n# Initialize LndNode\nAdd node data to the .env.shared file\n\n# Add API data\nSpecifics of the serivce to be used can be added to API_DOCS via utils.py\n\n# Instruction the AI agent\nInstructions can be delivered to the AI agent via agent_executor.invoke main.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightninglabs%2Flangchainbitcoin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flightninglabs%2Flangchainbitcoin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightninglabs%2Flangchainbitcoin/lists"}