Skip to main content

langchain-vdm-nexus

LangChain integration for VDM Nexus — signed-inference ChatModel that pays per call via x402 on Solana. No API keys, just an Ed25519 keypair.

ChatNexus is a drop-in subclass of langchain_core.language_models.chat_models.BaseChatModel. It runs the x402 v2 handshake transparently (probe → 402 → sign SPL USDC transfer → paid retry) and exposes the resulting Signed Inference Receipt and on-chain payment metadata on every response.

Install

pip install langchain-vdm-nexus

Two runtime deps: vdm-nexus (≥ 0.2.0) and langchain-core (≥ 0.3).

Use

import os
from langchain_vdm_nexus import ChatNexus
from langchain_core.messages import HumanMessage

llm = ChatNexus(
    secret_key=os.environ["AGENT_SECRET_KEY"],   # base58 64-byte Ed25519
    endpoint="https://nexus.vdmnexus.com/api/v1",
    model="openai/gpt-4o-mini",
    network="solana:mainnet",                    # or "solana:devnet"
)

reply = llm.invoke([HumanMessage(content="Why Ed25519?")])
print(reply.content)

A real mainnet receipt produced by this exact call shape: vdmnexus.com/r/c9710ea7-9e1f-46ee-aaa9-903a536ae12e.

Receipt access

The Signed Inference Receipt (SIR v2) and the x402 payment response are attached to every AIMessage:

reply = llm.invoke([HumanMessage(content="hello")])

receipt = reply.response_metadata["nexus_receipt"]
print("tx:        ", receipt["payment"]["tx_signature"])
print("paid:      ", receipt["payment"]["amount_usdc"], "USDC")
print("model:     ", receipt["model"])
print("hash:      ", receipt["response_hash"])

payment = reply.response_metadata["nexus_payment"]
print("settled at:", payment["txSignature"], "on", payment["network"])

Each receipt is cryptographically signed by the Nexus operator key and can be verified independently — see verify.vdmnexus.com or the @vdm-nexus/x402 TS verifier.

Async

ChatNexus implements both _generate and _agenerate. Use ainvoke, abatch, astream (single-chunk; see Streaming below) as normal:

reply = await llm.ainvoke([HumanMessage(content="hi")])

Compatibility

LangChain's BaseChatModel is the substrate that LangGraph nodes and CrewAI agents call into. ChatNexus works as-is in:

  • LangChain chains (llm | prompt | parser).
  • LangGraph — pass the model into any node that accepts a chat model. Receipts surface on the node's output state via last_message.response_metadata["nexus_receipt"].
  • CrewAI — use as the agent's llm. Every tool-call and reasoning step routes through Nexus and emits a receipt.

Native LangGraph and CrewAI sub-packages may follow if there's adoption demand, but neither needs one — ChatNexus is sufficient.

Streaming

Not implemented in v0.1.0. The upstream /chat/completions endpoint does not emit SSE chunks today. Calls into stream / astream will fall through to the default BaseChatModel behaviour: a single chunk containing the full response. Native streaming will arrive once the Nexus rail supports it.

How payment works

Each invoke runs the x402 v2 two-roundtrip handshake:

  1. POST /chat/completions — server replies 402 with an X-Payment-Required challenge declaring the price (USDC) and recipient.
  2. Build a partially-signed SPL TransferChecked transaction (via solders) for that price, signed by your Ed25519 keypair.
  3. POST again with X-Payment: <base64> — the server's facilitator co-signs as fee payer, broadcasts to Solana, runs inference, and returns the OpenAI body plus X-Nexus-Receipt and X-Payment-Response headers.

The agent's wallet is yours; Nexus never holds private keys.

License

MIT. See LICENSE.

Repo

Source lives in the VDM Nexus monorepo under packages/sdk-python-langchain.

Metadata

Release files for langchain-vdm-nexus 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-vdm-nexus 0.1.0
File Size Uploaded Provenance Actions
langchain_vdm_nexus-0.1.0.tar.gz 8.7 kB Without provenance Details for langchain_vdm_nexus-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-vdm-nexus 0.1.0
File Interpreter ABI Platform Actions
langchain_vdm_nexus-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_vdm_nexus-0.1.0-py3-none-any.whl

Total release size: 16.5 kB

Release files / langchain_vdm_nexus-0.1.0.tar.gz

Download URL langchain_vdm_nexus-0.1.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b52767643e08624fa9775dcffce4397969a64b5ff3c50f15691e52afbc72dcf2
BLAKE2b-256 checksum
How to use checksums
1591348788984c0c5d8a89ae058d074cec1d3f858aff025f1f8b3fbb48d1b905
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.14.2 HTTPX/0.28.1

Release files / langchain_vdm_nexus-0.1.0-py3-none-any.whl

Download URL langchain_vdm_nexus-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03a3f1773c7e93d25c02b9b66e9b18423c189e769615c18dd02f022fe205fa48
BLAKE2b-256 checksum
How to use checksums
fce88dd82a4581764941b0786ee2fefd765fd3dd1bf1647e273256e4ff11ba58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.14.2 HTTPX/0.28.1

Security for langchain-vdm-nexus 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page