Skip to main content

Multi-framework x402 payment SDK for AI agents — Python bindings for Life Agent OS Haima subsystem

Project description

haima

Multi-framework x402 payment SDK for AI agents. Add payments to your LangChain, LangGraph, or CrewAI agent in 5 minutes.

Install

pip install haima                    # Core SDK
pip install haima[langchain]         # + LangChain/LangGraph
pip install haima[crewai]            # + CrewAI
pip install haima[all]               # Everything

Quick Start

from haima import HaimaClient

async with HaimaClient(facilitator_url="https://haima.broomva.tech") as client:
    receipt = await client.pay(
        recipient="0x742d35Cc6634C0532925a3b844Bc9e7595916Da2",
        amount_micro_usd=100,
        task_id="translate-doc",
    )
    print(f"Settled: {receipt.receipt.tx_hash}")

LangChain / LangGraph

from haima.integrations.langchain import haima_pay_tool
from langgraph.prebuilt import create_react_agent

tool = haima_pay_tool(facilitator_url="https://haima.broomva.tech")
agent = create_react_agent(llm, [tool])

CrewAI

from haima.integrations.crewai import HaimaPayTool
from crewai import Agent

tool = HaimaPayTool(facilitator_url="https://haima.broomva.tech")
agent = Agent(role="Payment Processor", tools=[tool])

x402 Middleware

Transparent payment handling for any HTTP request:

from haima import HaimaWallet, X402Middleware

middleware = X402Middleware(wallet=HaimaWallet.generate())
response = await middleware.get("https://api.example.com/premium-data")
# 402 responses are auto-signed and retried

Configuration

Env Var Description
HAIMA_PRIVATE_KEY Wallet private key (hex)
HAIMA_FACILITATOR_URL Facilitator endpoint

How It Works

  1. Agent makes a payment request via client.pay()
  2. SDK signs the payment with the agent's secp256k1 wallet
  3. Signed payment submitted to Haima facilitator
  4. Facilitator settles on-chain via USDC (Base L2)
  5. Receipt returned with transaction hash

All amounts in micro-USD (1 USD = 1,000,000 μc).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

life_haima-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

life_haima-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file life_haima-0.1.0.tar.gz.

File metadata

  • Download URL: life_haima-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for life_haima-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5cf4caca7d70cbb1f956c3be6829378680a204bdc65968b06083f0c398fe3049
MD5 d24f37813bb1df84e98cba5ebab9f425
BLAKE2b-256 cf36ad6bb767da3175aac7518ae77be72b48cc394e8914430ae6d8f1424afe8b

See more details on using hashes here.

File details

Details for the file life_haima-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: life_haima-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for life_haima-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e954733ac6e4a37e5092885dbafc70776246b43a5b713128ad281dcfee18a89e
MD5 829b92d6a400966e4ea4bf51fbd0d994
BLAKE2b-256 0e8f317a481e7f408e0d695829cc76de7d6ec7b706c19101cab0c51e18af2c6d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page