MoltsPayTool - Let your LangChain agent pay for AI services

  Hey everyone! 👋                                                                                             
                                                                                                               
  I built a LangChain tool that lets agents pay for AI services autonomously using crypto (USDC on Base).      
                                                                                                               
  ## Quick Setup                                                                                               
                                                                                                               
  ```python                                                                                                    
  from langchain.agents import initialize_agent, AgentType                                                     
  from langchain_openai import ChatOpenAI                                                                      
  from moltspay.integrations.langchain import MoltsPayTool                                                     
                                                                                                               
  llm = ChatOpenAI(model="gpt-4")                                                                              
  tools = [MoltsPayTool()]                                                                                     
                                                                                                               
  agent = initialize_agent(tools, llm, agent=AgentType.OPENAI_FUNCTIONS)                                       
  result = agent.run("Generate a video of a cat dancing")                                                      

What it does

  • Agent discovers available services (video generation, transcription, etc.)
  • Checks prices
  • Pays with USDC (gasless - no ETH needed, uses x402 protocol)
  • Returns results

Install

  pip install moltspay[langchain]                                                                              

Links

Also works with CrewAI out of the box since CrewAI uses LangChain tools.

Would love feedback! What services would you want your agents to be able to pay for?

Interesting project. The autonomous payment flow is a nice addition, especially for agent-based workflows that need to call multiple paid services.

One question: have you considered adding spending limits or approval rules? For example, allowing an agent to automatically pay for low-cost tasks while requiring confirmation before larger transactions. It seems like that could make the tool more practical for production environments where cost control is important.

Looking forward to seeing how this evolves.