Skip to content

feat(agentflow): add x402 paid HTTP node for Pyrimid-compatible APIs#6377

Open
darshankumar97 wants to merge 2 commits into
FlowiseAI:mainfrom
darshankumar97:feat/x402-paid-http-agentflow
Open

feat(agentflow): add x402 paid HTTP node for Pyrimid-compatible APIs#6377
darshankumar97 wants to merge 2 commits into
FlowiseAI:mainfrom
darshankumar97:feat/x402-paid-http-agentflow

Conversation

@darshankumar97
Copy link
Copy Markdown

Summary

Adds a new Agent Flow node: HTTP (x402 / Pyrimid) for handling paid x402-compatible API requests inside Flowise.

This implementation enables:

  • HTTP request execution
  • automatic HTTP 402 detection
  • x402 payment settlement attempt flow
  • automatic retry handling after settlement
  • EVM wallet credential integration for Base-compatible payments

Tested against live Pyrimid paid endpoints.

Closes #6367


What Changed

Added new credential

  • x402EvmWallet

    • stores EVM private key
    • supports Base RPC configuration

Added new Agent Flow node

  • HTTP (x402 / Pyrimid)

    • configurable URL/method/query/body
    • automatic 402 payment flow handling
    • retry logic after settlement attempt
    • optional pricing/affiliate configuration

Added dependencies

  • @x402/axios
  • @x402/evm
  • viem

Testing Performed

Test endpoint used:

https://pyrimid.ai/api/v1/paid/agentzone-search?q=agent-commerce

Observed behavior:

  • Initial request correctly returns HTTP 402
  • x402 settlement flow triggers automatically
  • retry logic executes correctly
  • endpoint continues returning payment_required when wallet lacks sufficient Base USDC balance

This validates:

  • 402 detection
  • payment settlement integration
  • retry pipeline behavior
  • Flowise Agent Flow integration

Screenshots

screenshots :
image
image

Note: Full payment completion requires a wallet funded with Base USDC. Current testing validates the 402 detection, settlement attempt, and retry integration flow.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new 'X402PaidApi' node for Agentflow, enabling HTTP requests with automated x402 USDC payment settlement. The changes include the addition of the new node, a corresponding credential type, necessary package dependencies, and UI icon updates. The reviewer provided actionable feedback suggesting the use of loose equality (== null / != null) for nullish checks throughout the new node implementation to improve code consistency and readability.

Comment on lines +182 to +184
if (h?.key && h.value !== undefined && h.value !== null) {
requestHeaders[h.key] = String(h.value)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved readability and consistency with the project's coding standards, it's better to use != null for checking against both null and undefined.

                if (h?.key && h.value != null) {
                    requestHeaders[h.key] = String(h.value)
                }
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

Comment on lines +199 to +201
if (p?.key && p.value !== undefined && p.value !== null) {
params.append(p.key, String(p.value))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved readability and consistency with the project's coding standards, it's better to use != null for checking against both null and undefined.

                if (p?.key && p.value != null) {
                    params.append(p.key, String(p.value))
                }
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

}
client.onBeforePaymentCreation(async (ctx: { selectedRequirements: { amount?: string | number } }) => {
const raw = ctx?.selectedRequirements?.amount
if (raw === undefined || raw === null) return undefined
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved readability and consistency with the project's coding standards, it's better to use == null for checking against both null and undefined.

Suggested change
if (raw === undefined || raw === null) return undefined
if (raw == null) return undefined
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

Comment on lines +341 to +343
if (maybe !== undefined && maybe !== null) {
amountPaidAtomic = String(maybe)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved readability and consistency with the project's coding standards, it's better to use != null for checking against both null and undefined.

Suggested change
if (maybe !== undefined && maybe !== null) {
amountPaidAtomic = String(maybe)
}
if (maybe != null) {
amountPaidAtomic = String(maybe)
}
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

… node

Co-authored-by: Cursor <cursoragent@cursor.com>
@darshankumar97
Copy link
Copy Markdown
Author

Addressed the requested nullish-check style changes and pushed the updates. Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x402 payment node for paid agent tools

1 participant