Skip to content

feat: x402 payment agent sample — autonomous API payment handling #4938

@up2itnow0822

Description

@up2itnow0822

Feature Request

Problem

ADK has samples for MCP integration, RAG, multi-agent workflows, and dozens of other patterns, but no samples demonstrating how an agent handles paid API access. As agents interact with premium services, they need a standard way to handle HTTP 402 (Payment Required) responses.

Proposed Solution

Add a sample agent that handles x402 payment negotiation. When fetching from a paid API:

  1. Agent receives HTTP 402 with payment requirements
  2. Evaluates cost against spending policy (per-tx cap, daily limit, recipient allowlist)
  3. Signs a USDC payment proof
  4. Retries with payment header

Implementation

PR #4937 implements this with two tools (fetch_paid_api + get_spending_status) and a mock server for testing.

Context

The x402 protocol (by Coinbase) standardizes HTTP 402 payment negotiation. This pattern was recently merged into NVIDIA's NeMo Agent Toolkit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    tools[Component] This issue is related to tools

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions