Skip to main content

LangChain tool for x402 Service Discovery — find paid API services at runtime

Project description

langchain-x402-discovery

A LangChain BaseTool that lets any LangChain agent discover x402-payable API services at runtime via the x402 Service Discovery API. Instead of hardcoding service URLs, your agent queries the discovery catalog and finds the best available endpoint ranked by quality tier and price.

Install

pip install langchain-x402-discovery
# or without PyPI:
pip install requests langchain-core
# and copy x402discovery_langchain/__init__.py into your project

Usage

from x402discovery_langchain import X402DiscoveryTool
from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4o-mini")
agent = initialize_agent(
    tools=[X402DiscoveryTool()],
    llm=llm,
    agent=AgentType.OPENAI_FUNCTIONS,
    verbose=True,
)
result = agent.run("Find a web research API under $0.10 per call")
print(result)

The agent will call x402_discover(capability="research", max_price_usd=0.10) and return quality-ranked results with endpoint URLs and pricing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_x402_discovery-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_x402_discovery-1.0.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_x402_discovery-1.0.0.tar.gz.

File metadata

  • Download URL: langchain_x402_discovery-1.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for langchain_x402_discovery-1.0.0.tar.gz
Algorithm Hash digest
SHA256 03f15af630513c7eaee8300f58fe33eca1fa696263da480668602bf1890b8a3e
MD5 28062050543f2210929e76c264e871e8
BLAKE2b-256 c24258cb8cafbaa7cd9203258400febc6c3dce3b993a6df913bb6fd79269ab89

See more details on using hashes here.

File details

Details for the file langchain_x402_discovery-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_x402_discovery-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b0853784cc0eb97fb6cba752636c38a417d337690726dfa1ebb7161ee8ec280
MD5 ebc6ef7f0cd567ebffbac785258a2b25
BLAKE2b-256 846f978e5ddf41ab22e985656d1659383fcdfecee1b6d71b5cdcd04e3e52a548

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page