Skip to main content

matrx-batch

Cost-shield foundation for AI workloads in the Matrx ecosystem.

Three primitives:

  1. OpenAI Batch API + Anthropic Message Batches — submit JSONL, poll status, fetch results. Async wrappers over the provider SDKs.
  2. 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.
  3. Embedding cache — content-addressable (SHA256 of model || text) reuse of embedding vectors across the org. Backed by rag.embedding_cache via 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.

Metadata

Release files for matrx-batch 0.2.160

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matrx-batch 0.2.160
File Size Uploaded Provenance
matrx_batch-0.2.160.tar.gz 94.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for matrx-batch 0.2.160
File Interpreter ABI Platform
matrx_batch-0.2.160-py3-none-any.whl Python 3 none any Details

Total release size: 176.2 kB

Release files / matrx_batch-0.2.160.tar.gz

Download URL matrx_batch-0.2.160.tar.gz
Size 94.8 kB
Tags Source
SHA-256 checksum
How to use checksums
57253df3999f5c5a91d81cf34e8e72d05e0caf7fb48394ee243abc5f7b64e7d4
BLAKE2b-256 checksum
How to use checksums
de2e97ce1c43bef6e58f74317ed50e745d70d133425ce1a5ae5bac67f8023a82
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 Oct 23, 2026.

Transparency log

Release files / matrx_batch-0.2.160-py3-none-any.whl

Download URL matrx_batch-0.2.160-py3-none-any.whl
Size 81.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
385205f1fdd13ae32f2a0375c4e4e5c96eb0d29419f4acdc3e93a16e4b76a8b7
BLAKE2b-256 checksum
How to use checksums
4746bda4aeb3c2d29c79459245caea575d8cafa11b2102c98d433f6e3d2bc43d
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 Oct 23, 2026.

Transparency log

Security for matrx-batch 0.2.160

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for matrx_batch-0.2.160.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 Oct 23, 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.2.160 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