Skip to main content

langchain-idemcore

LangChain chat model for the Idemcore API. Every answer comes with a signed, independently verifiable, bit-exact receipt, stored on AIMessage.response_metadata.

Install guide: https://idemcore.net/integrations/langchain

Install

pip install langchain-idemcore
export IDEMCORE_API_KEY=ick_...

Requires idemcore>=0.3 (r2 receipts) and idemcore-verify>=0.3.6.

Quickstart

from langchain_core.messages import HumanMessage
from langchain_idemcore import ChatIdemcore, IdemcoreReceiptHandler, verify_langchain_receipt

llm = ChatIdemcore(model="your-model-id", max_tokens=64)
handler = IdemcoreReceiptHandler()

msg = llm.invoke(
    [HumanMessage(content="Name the three primary colours.")],
    config={"callbacks": [handler]},
)
print(msg.content)
print(msg.response_metadata["receipt_id"])   # rcpt_...
print(handler.to_jsonl())

# Local check of the signed receipt (and of a public token log, if you have one):
# bundle = verify_langchain_receipt(msg, log_text=log_text)
# print(bundle.ok, bundle.verification.levels)

Streaming works the same way: text arrives in chunks, and the receipt is attached to a later chunk's response_metadata once the answer is complete. Merging the AIMessageChunks (or using IdemcoreReceiptHandler) preserves it.

for chunk in llm.stream([HumanMessage(content="Write one short sentence.")]):
    print(chunk.content, end="")

Receipt metadata

AIMessage.response_metadata (and ChatResult.llm_output) contains:

  • receipt_id, receipt (the full signed r2 receipt)
  • salt (for hash_only receipts; store it with the conversation)
  • privacy, model, finish_reason, id, usage

IdemcoreReceiptHandler collects those payloads for a whole run and can write them as JSONL.

verify_langchain_receipt runs idemcore.verify_receipt (signature, optional token-log chain, optional prompt/answer commitments). When log_text is given it also runs the open idemcore-verify log check.

Sampling

Idemcore decoding is greedy: temperature is fixed at 0. Passing any other temperature, or sampling settings such as top_p, top_k, penalties, seed, n, or stop sequences, raises an error before a request is made. Tool and function calling are not supported.

max_tokens must be a whole number from 1 to 2048. privacy is hash_only (default) or full. Auth is IDEMCORE_API_KEY (or api_key=). Billing is measured server-side in tokens.

Tests

pip install -e ".[dev]"
pytest

Unit tests mock the SDK. A live smoke test runs only when IDEMCORE_API_KEY is set in the environment.

Metadata

Release files for langchain-idemcore 0.1.1

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-idemcore 0.1.1
File Size Uploaded Provenance Actions
langchain_idemcore-0.1.1.tar.gz 12.0 kB Without provenance Details for langchain_idemcore-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-idemcore 0.1.1
File Interpreter ABI Platform Actions
langchain_idemcore-0.1.1-py3-none-any.whl Python 3 none any Details for langchain_idemcore-0.1.1-py3-none-any.whl

Total release size: 22.5 kB

Release files / langchain_idemcore-0.1.1.tar.gz

Download URL langchain_idemcore-0.1.1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fc702f4962d675bd236312df4f9700b53ff2c78ef4f464446c289b13dc49732b
BLAKE2b-256 checksum
How to use checksums
495ccf3046e9d9ca8364e1b2f565e5b25fc4d00fa41d4d18c6cc94f9205e121a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / langchain_idemcore-0.1.1-py3-none-any.whl

Download URL langchain_idemcore-0.1.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70a91eea8ca8586b3dfcf00d4769bccac7cb82b8b563104302296726d8f33698
BLAKE2b-256 checksum
How to use checksums
318c751cd2ef58179bad07b06f4b6bdf0207bf974b42b401455f0d32117afee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for langchain-idemcore 0.1.1

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.

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