matrx-batch
Cost-shield foundation for AI workloads in the Matrx ecosystem.
Three primitives:
- OpenAI Batch API + Anthropic Message Batches — submit JSONL, poll status, fetch results. Async wrappers over the provider SDKs.
- Urgency router —
BatchRouter.submit(job)routes a job to live inference, to the provider's Batch API (50% discount, 24h SLA), or makes a cost-based decision automatically. - Embedding cache — content-addressable (SHA256 of
model || text) reuse of embedding vectors across the org. Backed byrag.embedding_cachevia a host-supplied asyncpg pool.
Dependency posture
matrx-batch sits one notch above matrx-utils in the dependency graph
and is consumed by matrx-rag (embedding cache) and matrx-ai (urgency
router, future). It MUST NOT import from aidream/ or from any other
matrx-* sibling — every cross-boundary dependency comes in via
matrx_batch.configure(...).
Usage (host-side wiring)
import matrx_batch
from openai import AsyncOpenAI
from anthropic import AsyncAnthropic
matrx_batch.configure(
openai_client=AsyncOpenAI(api_key=settings.OPENAI_API_KEY),
anthropic_client=AsyncAnthropic(api_key=settings.ANTHROPIC_API_KEY),
pool_factory=lambda: get_async_pg_pool(),
cost_check=_aidream_budget_precheck,
)
# Wire the cache into matrx-rag's embed() funnel
import matrx_rag
matrx_rag.configure(embedding_cache=matrx_batch.get_embedding_cache())
Usage (consumer)
from matrx_batch import BatchRouter, BatchableJob
router = BatchRouter()
receipt = await router.submit(
BatchableJob(
kind="chat",
provider="anthropic",
urgency="auto",
payload={"model": "claude-haiku-4-5", "messages": [...]},
estimated_tokens_in=8200,
)
)
See also
CLAUDE.md— package rules and injection-point contract.matrx_batch/embedding_cache.py— chunk-level embedding reuse.matrx_batch/router.py— urgency routing decisions.
Release files for matrx-batch 0.2.105
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| matrx_batch-0.2.105.tar.gz | 83.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| matrx_batch-0.2.105-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 156.0 kB
Release files / matrx_batch-0.2.105.tar.gz
| Download URL | matrx_batch-0.2.105.tar.gz |
|---|---|
| Size | 83.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
101d916db31eff53561fc030d0b62e995da77d6a5f87060c7a70176ca96efaf2
|
|
BLAKE2b-256 checksum How to use checksums |
8d8604647bf39cff3602a37613e457ca734781f8fa043d67385c0eb5c578a740
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 23, 2026.
Transparency logRelease files / matrx_batch-0.2.105-py3-none-any.whl
| Download URL | matrx_batch-0.2.105-py3-none-any.whl |
|---|---|
| Size | 72.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d193f5f5695be4c116e1ff2c0ceb3d662b33fe97ead1447f8668a0213d6fadb4
|
|
BLAKE2b-256 checksum How to use checksums |
d31cd7783753f544e44b26769270d58614642a8420ba2bce8f33014c726ed306
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 23, 2026.
Transparency log