ememdev: Python client for emem.dev
ememdev is the Python client for the emem.dev Earth
memory protocol. Use it when a Python program or agent must read signed
Earth-observation facts and keep the receipts for citation. On emem.dev a read
needs an account: make an API key at
emem.dev/account/connect and set
EMEM_API_KEY. The client sends it to emem.dev and to no other host.
pip install ememdev
export EMEM_API_KEY=emk_... # your key
python -c 'from ememdev import Client; print(Client().locate("Mount Fuji")["cell64"])'
The second line prints the cell64 address of Mount Fuji (defi.zb592.nUkO.zEzE
on 7 November 2026). For the protocol itself, read
docs/quickstart.md
and docs/agents.md.
What the client does
The Client class wraps the public REST surface. Each method sends one
request and returns the parsed JSON without changes. That JSON includes
the Ed25519-signed receipt and the content-addressed CIDs, so you can cite a
fact and verify it offline. The module docstring of ememdev.client maps
each endpoint to its method. The full REST surface is the list in
/openapi.json. This README gives no count,
because a count goes out of date.
The client does not wrap endpoints that do not return JSON over HTTP/1.1.
Examples are /v1/stream (SSE), the scene PNG and RGB images, and
/v1/attest_cbor. Call them with httpx directly. The module docstring
lists all of them.
Install
pip install ememdev
The PyPI distribution and the import package have the same name, ememdev.
The shorter name emem on PyPI belongs to a different project.
To install from a checkout of this repository:
pip install -e sdks/emem-py
The client needs Python 3.9 or later. Its runtime dependencies are
httpx and blake3, which ememdev.rlvr
uses for content ids and log hashes. To sign memory writes or verify
receipts offline, add the signing extra. It installs cryptography:
pip install "ememdev[signing]"
Read a fact
from ememdev import Client
with Client() as em:
cell = em.locate("Mount Fuji")["cell64"]
facts = em.recall(cell, bands=["copdem30m.elevation_mean"])
print(facts["facts"][0]["value"])
On 7 November 2026 this printed 3539.042236328125 (metres). If no fact
is in memory for the cell, recall fetches the source first. That first
read can take tens of seconds; the client timeout is 180 seconds.
Sign in with an API key
Since 1 December 2026, emem.dev needs an emem account for every MCP endpoint
and for most REST routes. Make an API key at
emem.dev/account/connect, then set
EMEM_API_KEY or pass it to the constructor:
from ememdev import Client
em = Client(api_key="emk_...") # or Client() with EMEM_API_KEY set
The client sends the key as Authorization: Bearer <key>, and only to the
scheme, host and port of its own base_url. It sends no key on the routes
that answer without an account: discovery, the catalogue, the transparency
log, content by its content id, token resolution and the receipt verifier.
If one of those routes asks for an account all the same, the client sends
the request once more with the key. It never logs or prints the key.
A refused credential raises ememdev.EmemAuthError, a subclass of
EmemHTTPError. Its message names where keys are made, and key_sent says
whether the request carried one: False means no key was set, True means
the key was revoked, expired or mistyped. A key without the scope a call
needs raises it with status 403. A node you run yourself without accounts
needs no key, and the client sends one only if you set it.
Use the async client
import asyncio
from ememdev import AsyncClient
async def main() -> None:
async with AsyncClient() as em:
out = await em.ask("How tall is Mount Everest?")
print(out["answer"])
asyncio.run(main())
AsyncClient has the same methods as Client.
Configure the client
| Environment variable | Default | Effect |
|---|---|---|
EMEM_BASE_URL |
https://emem.dev |
Responder root. Set it to use a self-hosted node. |
EMEM_TIMEOUT_SECS |
180 |
HTTP timeout in seconds. It matches the gateway timeout. |
EMEM_API_KEY |
unset | The account key sent to EMEM_BASE_URL. emem.dev needs one for most reads. |
You can also give base_url=, timeout= and api_key= to the constructor.
Write a signed note
On emem.dev a read or a write needs an account key. A write into the agent
memory namespace must also carry an Ed25519 attester block. The MCP client cannot make that signature for you.
ememdev[signing] makes it from a persistent identity, so one command
writes a signed note.
The key owns your namespace at /memories/by_attester/<pubkey8>/..., so
the client uses the same identity in every session. It looks for the key
in this order:
EMEM_AGENT_KEY: a 64-character hex seed or the path of a key file.~/.emem/agent_ed25519.pem. SetEMEM_HOMEto use a different directory.- If there is no key, the client makes one at that path with mode
0600.
From the command line, for an agent that already uses emem over MCP:
ememdev whoami # your pubkey and namespace_root
# write only the attester block to stdout; no network call:
ememdev sign --verb create --path /memories/by_attester/<you>/note.md --stdin < note.md
# sign a create and POST it to /mcp in one step (this is a write to emem.dev,
# and sends EMEM_API_KEY to --base-url):
ememdev write --path /memories/by_attester/<you>/note.md --body-file note.md
In Python:
from ememdev import load_or_create_signer
signer = load_or_create_signer() # persistent identity
path = f"{signer.namespace_root}/note.md"
body = b"a durable, signed, citeable note"
attester = signer.attester_block("create", path, body)
# POST {path, file_text, kind, attester} to /mcp emem_memory_create.
Each block uses the v2 preimage, which binds base: the file_cid that is at
the path now. A create with no base signs absent, for a new path. To
overwrite a note, pass base=<its file_cid> (ememdev write --base). The
other verbs change a note that exists, so they need base.
For str_replace and insert, sign the whole file after the edit. For
rename, use signer.rename_attester_block(old, new), which signs both
paths. The ememdev.signing docstring gives the body rule for each verb.
The server refuses a write into the namespace of a different key with a 403.
The sign and write commands refuse it locally before they send anything.
Cite and verify a receipt
Every response from a read primitive (for example recall) has a receipt
block. Some responses, such as locate, have none. A receipt contains these
fields:
responder_pubkey_b32: the Ed25519 public key, base32 without padding, lowercase.signature_b32: the Ed25519 signature over the BLAKE3 preimage digest.preimage_version: the rule that made the signature. Read it; do not assume it.merkle_proof: the inclusion proof forfact_cids[0], if the log recorded one.fact_cids[]: the BLAKE3 CIDs of all facts in the response.
To cite an answer, quote receipt.fact_cids[0] and the responder pubkey.
Anyone can verify the signature offline. With the signing extra installed,
ememdev.verify does the check in your process:
from ememdev import Client
from ememdev.verify import verify_receipt_offline
with Client() as em:
cell = em.locate("Mount Fuji")["cell64"]
resp = em.recall(cell, bands=["copdem30m.elevation_mean"])
v = verify_receipt_offline(resp["receipt"])
print(v.ok, v.state, v.signer_b32)
On 7 November 2026 this printed True verified 777er3yi... with
preimage_version 2. The function checks the signature against the key in
the receipt. Compare v.signer_b32 with the key you trust, for example
federation.node.responder_pubkey_b32 in
https://emem.dev/.well-known/emem.json. On 7 November 2026 the two keys
were the same. The function does not raise and does not use the network.
If no check ran, v.ok is False and v.state gives the cause.
Without the extra, the state is crypto_unavailable. If the local encoders
disagree with the Rust test vectors, the state is self_test_failed.
Client.verify_receipt() is different: it asks the
responder to do the check.
Keep and forward the receipt whole. ememdev returns it without changes;
store it and pass it on the same way. From preimage_version: 2, the
signature also covers the inclusion proof. Thus a party between you and the
reader cannot remove the proof without detection.
The cost is that a changed receipt fails. Remove merkle_proof, rename a
field or summarise the envelope, and the check gives
signature_valid: false. That result looks the same as a forgery, although
nobody changed the data. If the responder can prove that someone reshaped
the receipt, POST /v1/verify_receipt gives reason: receipt_reshaped_after_signing instead of signature_invalid. It never
accepts the changed receipt.
Verify an RLVR reward offline
emem's RLVR engine (Reinforcement Learning with Verifiable Rewards) scores
forecasts of physical quantities, such as the 2 m temperature at a place at
a time to come. ememdev.rlvr computes the same numbers in Python, so you
can check a reward and a time proof without asking emem.dev. It is a port of
the Rust crate emem-rlvr. The tests compare it with vectors that the crate
wrote: task cids and their CBOR, reference forecasts, rewards, leaderboard
skill, the tasks a deck issues, commit bytes, and RFC 3161 requests. Every
value is the same, byte for byte or float for float.
BLAKE3 for content ids and log hashes installs with the package. The
authority's signature check needs cryptography, from the signing extra.
Recompute a task's cid and a reward:
from ememdev.rlvr import Forecast, Form, Reference, Resolution, Task, reward
task = Task(
v=1, deck="", cell="defi.zb64a.cAzU.zfa27", band="era5.t2m", reader="era5@1",
window=(1796470200, 1796473800), resolution=Resolution.nearest(1796472000),
lock=1796211000, form=Form.quantiles([0.1, 0.5, 0.9]),
reference=Reference.climatology(10, 7), scale=1.8,
)
print(task.cid())
ref = Forecast.quantiles([270.772, 273.85, 277.023])
print(reward(task, Forecast.quantiles([272.0, 274.5, 277.25]), ref, 275.1))
This prints ccwm2u7kv3tu2fkstjp27stspf4hisn4i4ihpghbkzv6onkqja2q and a
Scored with reward=0.15744444444444153, the values in the Rust crate's
vectors.
A time proof shows that a log entry, such as an agent's commit, existed by an outside authority's clock. It has three links: the entry is in a tree head, an anchored head is a prefix of that head, and an RFC 3161 token from the authority stamps the anchored head. Check one from the command line:
ememdev rlvr verify-proof proof.json token.tsr --ca-file /etc/ssl/certs/ca-certificates.crt
With proof-12345.json and anchor-3487000.digicert.tsr from
sdks/emem-py/tests/vectors/rlvr/, the first line is
existed by 2026-11-29T12:54:26Z (unix 1795956866), by the authority's clock.
The exit status is 0 when every link holds and the signature verified, 1
when a link is broken (the output names it), and 3 when the links hold but
the signature was not checked.
In Python, fixed_in_time(task, proof) returns the stamped second, or
raises a ProofError that names the broken link: AfterAnchor,
Inclusion, Consistency, Anchor (the token stamps other bytes) or
Late (the stamp is not strictly before the task's lock).
from ememdev.rlvr import TimeProof, fixed_in_time, parse_response, verify_token
with open("proof.json") as f, open("token.tsr", "rb") as t:
proof = TimeProof.from_json(f.read(), parse_response(t.read()))
when = fixed_in_time(task, proof)
v = verify_token(proof.token, "/etc/ssl/certs/ca-certificates.crt")
print(when, v.ok, v.signer)
What the checks cover:
fixed_in_timedoes not check the authority's signature, as in the Rust crate.verify_tokendoes. It checks that the signed attributes bind the token's content, that the signature verifies with the key of the signer's certificate (RSA PKCS #1 v1.5, ECDSA or Ed25519), that the certificate is for time-stamping only, and that it chains to a certificate in the CA file you pass.v.okisTrueonly when every check ran and passed. When a check cannot run here, for example for an RSASSA-PSS signature or a SHA-1 digest,v.stateisnot_checkedandv.okisFalse.- Certificates are checked at the token's genTime. Revocation, certificate policies and name constraints are not checked.
verify_with_opensslrunsopenssl ts -verifyinstead. It runs only when you call it, and openssl checks certificates at the current time.- On 29 November 2026 the DigiCert and Sectigo tokens in the test vectors
verified against
/etc/ssl/certs/ca-certificates.crt. The FreeTSA token verified against FreeTSA's own root, which is not in that file. - A valid proof shows when the forecast was fixed. It does not show that the outcome reading is correct: a reward is only as sound as the signed readings it is computed from.
Train, evaluate and research with RLVR
Three modules connect a multi-agent system to the RLVR engine. They use only
the Python standard library, so they run without httpx. The account key comes
from $EMEM_API_KEY (or api_key=) and follows the client's rule: it goes to
the base URL only, and not on the open routes (decks, tasks, results, traces,
transcripts, facts). Opening and closing an episode and a commit need it,
with the publish scope. An episode's own MCP address needs no key.
ememdev.rlvr.env:ReplayEnv, a Gymnasium-style environment over replay episodes.reset(as_of=...)opens one and returns its tasks and its bounded tool address;step({task: forecast})answers, closes the episode, and returns the rewards with the signed records and the transcript token ininfo.run_replaysruns many, within the server's caps, and writes each episode's rows to a JSONL file as it closes.ememdev.rlvr.export: a key's trace (with its?format=jsonltraining lines) and a replay episode's records as dataset rows that keep their provenance, written as JSONL or Parquet (with theparquetextra), andverify, which re-checks the rows offline (with thesigningextra).ememdev.rlvr.evals: a deck's open tasks as an evaluation set, a fixed rule that reads a model's answer, and scores from the result route.
from ememdev.rlvr.env import ReplayEnv
env = ReplayEnv("era5-t2m-72h")
obs, info = env.reset(as_of="2025-06-01")
obs, reward, done, _, info = env.step({t["cid"]: [20.0, 23.0, 26.0] for t in obs["tasks"]})
print(reward, info["status"], info["transcript"]["token"])
The guide, with the limits (replay is leak-limited, a live task is contamination-resistant, the live outcome is an ERA5 reanalysis value), is at emem.dev/docs/train-and-evaluate.html.
License
Apache-2.0, the same license as the protocol.
Metadata
Release files for ememdev 2.5.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 |
|---|---|---|---|---|
| ememdev-2.5.0.tar.gz | 131.2 kB | With provenance | Details for ememdev-2.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ememdev-2.5.0-py3-none-any.whl | Python 3 | none | any | Details for ememdev-2.5.0-py3-none-any.whl |
Total release size: 280.3 kB
Release files / ememdev-2.5.0.tar.gz
| Download URL | ememdev-2.5.0.tar.gz |
|---|---|
| Size | 131.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c94ecb1b24bb25b56ee1b4c9c1bdf3f756dcf467009590e79a3511c9df863675
|
|
BLAKE2b-256 checksum How to use checksums |
c9f405b813ead20872a25fa35c3ce8bfcb596b27b2332b07fdc880fc8e810071
|
| 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 Dec 2, 2026.
Transparency logRelease files / ememdev-2.5.0-py3-none-any.whl
| Download URL | ememdev-2.5.0-py3-none-any.whl |
|---|---|
| Size | 149.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7f62d3fc45cd3726c2dd4d414f78182274050972fd420e63b99b0855a1cdb65
|
|
BLAKE2b-256 checksum How to use checksums |
690ef31f5563568757345a38757d6b3b5ae0c3f4f3955383f14fa3527a316295
|
| 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 Dec 2, 2026.
Transparency logSecurity for ememdev 2.5.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ememdev-2.5.0.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 Dec 2, 2026.
Transparency logA 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.