Skip to content

Conversation

@vvsotnikov
Copy link

Description

Problem

Hey, I tried installing x402 for a FastAPI project and noticed it installs all frameworks and clients (Flask, FastAPI, httpx, requests) as hard dependencies, even if you only need FastAPI.

This causes unnecessary bloat, potential version conflicts, and makes it harder to add new integrations in the future as more middleware and clients are added.

Solution

I propose moving framework and client deps to optional extras, with graceful import errors when missing.

This avoids import-time coupling and keeps the package lean and extensible for future integrations.

pip install x402[fastapi,httpx]   # only what you need
pip install x402[all]             # everything

Extras: flask, fastapi, httpx, requests, servers, clients, all

Added clear errors when deps are missing:

ImportError: httpx client requires the httpx package. Install with: pip install x402[httpx]

Breaking Changes

Frameworks and clients are no longer installed by default:

pip install x402[fastapi,httpx]  # or pip install x402 fastapi httpx

Clients are now imported from their submodules:

# before: from x402.clients import x402HttpxClient
# after:
from x402.clients.httpx import x402HttpxClient

I was considering using lazy imports instead, but it would've increased maintenance costs and probably is bad r/r.

Tests

No new tests needed. All existing tests are passing.

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits

@cb-heimdall
Copy link

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@vercel
Copy link

vercel bot commented Dec 30, 2025

@vvsotnikov is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants