Skip to main content

idemcore (Python SDK)

Python client for the Idemcore API. Every chat answer comes with a signed receipt, and this package can check that receipt on your own machine.

  • Chat completions (plain or streaming) that return the answer text and its receipt id.
  • Fetch a receipt and its public token log.
  • Verify receipts locally: Ed25519 signature (L1), token-log chain (L2), and your prompt / answer against the receipt's salted commitments (disclosure).
  • Server-side checks: remote verify, replay on an independent build (L3), audit export.
  • Sync and asyncio clients. Python 3.9+. Dependency: cryptography. To check format v2 logs, use the open verifier idemcore-verify (0.4.0 or later).

Decoding is greedy: temperature is fixed at 0 (and n at 1). Sending any other temperature raises InvalidRequestError before a request is made.

Install

pip install idemcore

Get an API key

  1. Sign in to the console at https://console.idemcore.net/#/login (the public preview is free, with preview limits).
  2. Create an API key. It starts with ick_ and is shown only once.
  3. Export it:
export IDEMCORE_API_KEY="ick_..."

The client reads IDEMCORE_API_KEY (and, optionally, IDEMCORE_BASE_URL, default https://api.idemcore.net). You can also pass Idemcore(api_key=...).

Quickstart

from idemcore import Idemcore

client = Idemcore()
model = client.models()[0]["id"]   # pass a model id explicitly

r = client.chat("Name the three primary colours.", model=model, max_tokens=64)
print(r.text)
print(r.receipt_id)          # rcpt_...

# Verify on this machine: signature, token-log chain, and that the receipt
# commits to exactly this prompt and this answer.
result = client.verify_local(r)
print(result.ok)             # True
for name, level in result.levels.items():
    print(name, level.ok, level.errors)

r.receipt is the full signed receipt, r.salt the base64url salt of a hash_only receipt (the default privacy mode). Anyone with the salt and the text can check the commitments, so keep the salt with the conversation.

Streaming

with client.chat_stream("Write a haiku about receipts.", model=model) as stream:
    for chunk in stream:
        print(chunk.delta, end="", flush=True)

print()
print(stream.result.receipt_id)   # the receipt arrives with the last chunk

Async

import asyncio
from idemcore import AsyncIdemcore

async def main():
    client = AsyncIdemcore()
    model = (await client.models())[0]["id"]
    r = await client.chat("Hello", model=model)
    print(r.text, r.receipt_id)

asyncio.run(main())

Receipts, logs and server-side checks

receipt = client.get_receipt("rcpt_...")             # GET /v1/receipts/{id}
log = client.get_receipt_log("rcpt_...")             # GET /v1/receipts/{id}/log
print(log.log_format)                                # idemcore-log/r1-public

client.verify_remote(r.receipt, messages=r.messages, salt=r.salt,
                     output_token_ids=r.output_token_ids)   # POST /v1/receipts/verify
client.replay_result(r)                              # POST /v1/receipts/replay (L3)
lines = client.audit_export("2026-10-01", "2026-10-31")     # POST /v1/audit/export (NDJSON lines)
client.models()                                      # GET /v1/models
client.keys()                                        # GET /v1/keys (signing keys, JWKS)

Offline verification without the client

from idemcore.verify import verify_receipt

res = verify_receipt(receipt, log_text=log_text,
                     messages=messages, salt=salt, output_token_ids=output_ids)

The production receipt-signing public key is bundled (idemcore.verify.DEFAULT_TRUSTED_KEYS); pass keys=client.keys() to use the live key set instead.

Reproducible agents (record, replay, verify)

Record a whole agent run (model calls with their receipts, tool calls, approvals) as a hash-chained trace, verify it offline, and replay it with a bit-identical check. Recorded tool results are fed back, so tools never run twice.

from idemcore import trace
s = trace.Session(client)
city = s.chat("Which city is the Eiffel Tower in? One word.", max_tokens=8).text
w = s.tool("get_weather", {"city": city}, get_weather)
s.save("run.trace.json")
python -m idemcore trace verify run.trace.json
python -m idemcore trace replay run.trace.json

See docs/agent-replay.md (Tiếng Việt) and examples/agent_replay.py.

Errors

All errors derive from idemcore.IdemcoreError and carry status, type and message: AuthenticationError (401), PermissionDeniedError (403, key lacks a scope), NotFoundError (404), ConflictError (409), InvalidRequestError (400/415), RateLimitError (429, see .retry_after), InsufficientQuotaError (429), ServiceUnavailableError (503), InternalServerError (5xx), APIConnectionError (network). GET requests are retried on 429/503 (max_retries, default 2); chat requests are never retried automatically, so a retry never creates a second receipt behind your back.

Using the OpenAI SDK instead

The API is OpenAI-compatible, so openai.OpenAI(base_url="https://api.idemcore.net/v1", api_key=...) also works; the receipt is in the response's idemcore_receipt field. This package adds typed receipts and local verification.

Development

pip install -e .
python -m unittest discover -s tests          # mocked API, no network
IDEMCORE_LIVE=1 python -m unittest tests.test_client.LiveSmoke   # GET /health only

License

Apache-2.0

Metadata

Release files for idemcore 0.3.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 idemcore 0.3.1
File Size Uploaded Provenance Actions
idemcore-0.3.1.tar.gz 33.6 kB With provenance Details for idemcore-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 67.0 kB

Release files / idemcore-0.3.1.tar.gz

Download URL idemcore-0.3.1.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3856f481341412cc8d52efe8076c7f94c17a4fcf5b0da8709b55ee1c6bc94067
BLAKE2b-256 checksum
How to use checksums
5a4563f4147ae3ade9c8bca297cd82316c7e731f806e08e4544a45aa0cebad53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / idemcore-0.3.1-py3-none-any.whl

Download URL idemcore-0.3.1-py3-none-any.whl
Size 33.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
231bce990b7ac1f3cc07c90c42c5eaa2caf65057ae2d37c9a4f31677658729e3
BLAKE2b-256 checksum
How to use checksums
8a775c8b562f12e888f0e692cc4cd749ae212737463697087653811b09aef497
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for idemcore 0.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for idemcore-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

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.3.1 This release

2 release files Full 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