Documentation Index
Fetch the complete documentation index at: https://docs.delegare.dev/llms.txt
Use this file to discover all available pages before exploring further.
Delegare Toolkit
The Delegare toolkit enables your LangChain and LangGraph agents to execute payments, check budgets, and handle x402-gated content automatically via the Delegare API. Unlike standard payment gateways, Delegare issues an Intent Mandate (SD-JWT-VC) rather than returning raw card details. The agent uses this mandate to request charges up to the user’s pre-authorized budget, ensuring payments are entirely separated from the LLM context.Setup
First, you need to install thelangchain-delegare package:
Initializing the Toolkit
You can instantiate theDelegareToolkit using environment variables or by passing your credentials explicitly. It’s recommended to define an allowed_amounts_cents whitelist for safety.
Available Tools
The toolkit provides 7 unique tools designed for distinct phases of the agent payment lifecycle:setup_spending_mandate: Generates a one-time browser link for the user to securely input their card/wallet.poll_setup_session: Checks if the user completed the setup. Once completed, returns theintentMandatestring.check_mandate_balance: Retrieves the remaining budget of an active intent mandate.authorize_agent_payment: Executes a charge against a mandate (enforced server-side).delegare_fetch: Fetches URLs and automatically resolves HTTP 402 errors using the mandate.revoke_mandate: Cancels an active mandate.verify_receipt: Cryptographically verifies theX-PAYMENT-RESPONSEpayload of a settled charge.
Usage in an Agent
Here is a full example showing how to initialize the tools and connect them to an agent built with LangGraph.Agent with Budget Awareness
Delegare provides a customDelegareBudgetCallbackHandler that intercepts tool completions and monitors mandate budgets automatically to stop LLMs from overspending before the Delegare API physically rejects the transaction.
LangGraph Idempotency
When dealing with payments, idempotent execution is critical. If a LangGraph workflow crashes and retries, you want to guarantee the agent doesn’t double-charge the user. The integration providesget_idempotency_key which securely hashes LangGraph thread states into deterministic UUIDs.
Runnables and LCEL
For seamless data retrieval requiring x402 payment headers, you can use theX402AutoPayRunnable directly in your LCEL chains. It catches 402 errors, executes the required micro-payment via the intent mandate, and retries the fetch autonomously.