langchain-synapse
Dead-simple LangChain integration for the
Synapse decentralized inference network. Wraps the orchestrator's
POST /api/infer endpoint as a standard LangChain LLM so Synapse plugs into
any chain, agent, or RAG pipeline.
Install
From PyPI:
pip install synapse-langchain
From source:
cd integrations/langchain-synapse
pip install -e .
Distribution name on PyPI is
synapse-langchain; the Python import name islangchain_synapse(unchanged).
Use
from langchain_synapse import SynapseLLM
llm = SynapseLLM(
token_id="1", # model NFT id
user="0x0000000000000000000000000000000000000001", # your wallet
base_url="http://localhost:8000", # orchestrator
max_tokens=128,
)
print(llm.invoke("Hello from LangChain!"))
Works with LCEL out of the box:
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
chain = ChatPromptTemplate.from_template("Q: {q}\nA:") | llm | StrOutputParser()
chain.invoke({"q": "What is decentralized inference?"})
Demos
# Make sure the orchestrator is running:
# ROLE=orchestrator uvicorn backend.main:app --port 8000
python examples/demo.py
python examples/chain_demo.py
Config
| Param | Env var | Default |
|---|---|---|
base_url |
SYNAPSE_API_URL |
http://localhost:8000 |
token_id |
— | required |
user |
— | required |
session_id |
— | random bytes32 (demo) |
max_tokens |
— | 128 |
parameters |
— | None (pipeline kwargs) |
session_idmust come fromMarketplace.openSessionfor real paid runs. Leave itNoneonly when demoing against a dev orchestrator.
How it works
SynapseLLM._call just POSTs to /api/infer with the Synapse
InferenceRequest shape and returns
outputStr from the response. That's the entire integration — 60-ish lines.
Metadata
Release files for synapse-langchain 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| synapse_langchain-0.1.0.tar.gz | 4.3 kB | Without provenance | Details for synapse_langchain-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| synapse_langchain-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for synapse_langchain-0.1.0-py3-none-any.whl |
Total release size: 8.9 kB
Release files / synapse_langchain-0.1.0.tar.gz
| Download URL | synapse_langchain-0.1.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08bf4e8d6b34d51f04d110640d00faea16304b246a6eb6f1c44da4ee1b1a6bf3
|
|
BLAKE2b-256 checksum How to use checksums |
fb318ac6228d372b888a423b9a5e6885a74c9b96fe768e5174d5c38ee1ab609e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / synapse_langchain-0.1.0-py3-none-any.whl
| Download URL | synapse_langchain-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
008ce93f3b4480bb5fe8db1aef142f605c9e94bf8b1ea6131c621b459bb5d7bc
|
|
BLAKE2b-256 checksum How to use checksums |
caf234de1b4c75c350e32d0294111e007c6fda016ecf18cb745892b831c38929
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for synapse-langchain 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.