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.2

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

Built distribution (wheel)

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

Total release size: 22.5 kB

Release files / langchain_idemcore-0.1.2.tar.gz

Download URL langchain_idemcore-0.1.2.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ca6f431f8b85d99ce044c2917a16ac807c98090589ebec160876d020b4b86909
BLAKE2b-256 checksum
How to use checksums
60a52e1aade2df89a3213bfc3c3f800ae0e97cef413ca30c707a6e2d910a73a4
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.2-py3-none-any.whl

Download URL langchain_idemcore-0.1.2-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
002652ea7926352ac6979b99f478e12c8628b8b642b7f9987192f56a82cb414e
BLAKE2b-256 checksum
How to use checksums
f704421ff579381216370a73bdccf7f1b1d0aff71010423767fbc57e6b26cb7b
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.2

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