#4613·composio

[Feature]: x402 pay-per-call settlement on the tool-execution path

Author: dhyabi2Created Sep 24, 2026Updated Sep 26, 2026
Labelsfeature-request

Feature Request

Composio agents execute distributed tools for AI agents. Some of the most useful third-party tools are now priced per call over x402 (HTTP 402 Payment Required): an unpaid request returns an accepts[] envelope naming the payment schemes and assets it takes, the caller signs a payment for the quoted price, and retries to get the result. OpenSea, MetaMask, Nory and the x402 spec document this flow (e.g. https://docs.opensea.io/docs/x402). A Composio agent that hits a 402 on one of its tools currently has no step to complete the handshake and retry — it just fails, or the developer has to bolt on a bespoke billing backend.

This request: give Composio's tool-execution path a native pay-per-call handling — when a tool returns 402 Payment Required with a valid accepts[] envelope, read the payment requirements, and if a payer is configured, produce the per-call authorization and retry before returning the result (scope it to explicit 402 + valid envelope so it fails cleanly with no money moved on malformed responses).

Area of Improvement: Integrations / Toolkits (and MCP Server / Agentic Providers — an x402 MCP tool is the natural first case)

Feature Name: x402 pay-per-call settlement on the tool-execution path

Describe the Feature:

  • On a tool response of 402 Payment Required, parse the accepts[] payment envelope from the body.
  • If a payer is configured for one of the accepted schemes/assets, sign the per-call payment for the quoted price, retry the tool call, and return the paid result.
  • If no payer applies or the envelope is malformed, surface a clear "payment required" signal rather than a generic failure — no money moves automatically.

Use Case / Motivation:

  • More and more agent-useful APIs (inference, scraping, data, code execution) are priced per call and served over x402 instead of subscription/API-key programs. Composio agents that call them should be able to pay in-flow, the same way they switch tools or auth today.
  • Prior interest already exists on the repo: #3068 ("agentwallet-sdk — non-custodial payments for AI agents (x402, on-chain spend limits)") and #2583 (a Nory x402 payment example). This generalizes that into first-class 402 handling so any x402-priced tool works.

Proposed Solution or API Design (Optional):

  • composio.tools.execute(...) accepts an optional payer configuration; on a 402 response with a supported scheme it signs and retries transparently.
  • Or an x402 "payment tools" toolkit (mirroring the example pattern in #2583) exposing get_payment_requirements / authorize_payment / get_paid_result as tools an agent can call explicitly.

Who does this impact?

  • Developers using the SDK
  • AI Agent frameworks (LangChain, OpenAI, etc.)
  • End users of connected apps

Related Issues / References

Would you like to contribute to this feature?

  • Yes, I can help implement it

Additional Context The x402 scheme is rail-agnostic; accepts[] names a scheme/network/asset. One settlement rail keeps it feeless and instant for sub-cent per-call pricing — Nano (XNO) settles in under a second at zero fee with no merchant account and no gas, which makes fraction-of-a-cent per-call tool pricing practical for both the tool seller and the agent buyer.