Skip to content

Feat(x402): add payment protocol support#65

Merged
Benjpoirier merged 8 commits intomainfrom
feat/x402-payment-protocol-support
Mar 19, 2026
Merged

Feat(x402): add payment protocol support#65
Benjpoirier merged 8 commits intomainfrom
feat/x402-payment-protocol-support

Conversation

@Benjpoirier
Copy link
Copy Markdown
Contributor

@Benjpoirier Benjpoirier commented Mar 18, 2026

Description

Summary

  • Add support for the x402 payment protocol, allowing clients to
    automatically handle HTTP 402 responses by signing and retrying requests with
    on-chain payments
  • Introduce LinkupX402Signer protocol and create_x402_signer helper that
    wires up x402[httpx,evm] for Base chain EVM payments
  • Add LinkupPaymentRequiredError for cases where a 402 is received but cannot
    be handled (e.g. no signer configured, signing failure)
  • Merge base headers (User-Agent, Authorization) with payment headers on
    retry, matching JS SDK behavior

Usage

  from linkup import LinkupClient
  from linkup.x402 import create_x402_signer

  signer = create_x402_signer(private_key="0x...")
  client = LinkupClient(x402_signer=signer)

  result = client.search(
      query="What is x402?",
      depth="standard",
      output_type="sourcedAnswer",
  )

Checklist

  • I have installed pre-commit on this project (for instance with the make install-dev command)
    before creating any commit, or I have run successfully the make format-lint command on my
    changes.
  • I have run successfully the make test command on my changes.
  • I have updated the README.md if my changes affected it.

@Benjpoirier Benjpoirier force-pushed the feat/x402-payment-protocol-support branch from a772f45 to f147bb6 Compare March 18, 2026 16:17
@Benjpoirier Benjpoirier force-pushed the feat/x402-payment-protocol-support branch from f147bb6 to e419f11 Compare March 18, 2026 16:21
@Benjpoirier Benjpoirier requested a review from cjumel March 18, 2026 16:23
@Benjpoirier Benjpoirier force-pushed the feat/x402-payment-protocol-support branch from a37f5ec to 2ec96ba Compare March 19, 2026 13:57
@Benjpoirier Benjpoirier requested a review from cjumel March 19, 2026 13:57
Copy link
Copy Markdown
Contributor

@cjumel cjumel left a comment

Choose a reason for hiding this comment

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

Looks almost good! Just left very small and not important comments, one more important one is: since we've setup the CI with automatic release with semantic versioning and I assume that you're going to squash & merge this branch, you should make sure that the PR title follows the conventional commit convention, so that it's parsed as expected 🙂

@Benjpoirier Benjpoirier requested a review from cjumel March 19, 2026 15:53
Copy link
Copy Markdown
Contributor

@cjumel cjumel left a comment

Choose a reason for hiding this comment

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

See my previous comment

@Benjpoirier Benjpoirier changed the title Feat/x402 payment protocol support Feat(x402): add payment protocol support Mar 19, 2026
Copy link
Copy Markdown
Contributor

@cjumel cjumel left a comment

Choose a reason for hiding this comment

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

@Benjpoirier Benjpoirier merged commit b8d3f1a into main Mar 19, 2026
2 checks passed
@Benjpoirier Benjpoirier deleted the feat/x402-payment-protocol-support branch March 19, 2026 16:09
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.

2 participants