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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matrx_batch-0.2.30.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrx_batch-0.2.30-py3-none-any.whl (44.2 kB view details)

Uploaded Python 3

File details

Details for the file matrx_batch-0.2.30.tar.gz.

File metadata

  • Download URL: matrx_batch-0.2.30.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matrx_batch-0.2.30.tar.gz
Algorithm Hash digest
SHA256 b0b100e990a784b9662992f99ba152101f392310e9293d76ccb040c1c949ecff
MD5 24073592abd8f2cbb00fe64a6c067862
BLAKE2b-256 9973bba935651c1dc948a0a5ab028b304a53b2c9267575b8cb1a971816a460dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrx_batch-0.2.30.tar.gz:

Publisher: publish-package.yml on AI-Matrix-Engine/aidream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matrx_batch-0.2.30-py3-none-any.whl.

File metadata

  • Download URL: matrx_batch-0.2.30-py3-none-any.whl
  • Upload date:
  • Size: 44.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matrx_batch-0.2.30-py3-none-any.whl
Algorithm Hash digest
SHA256 85942244742b5a4cd76d92b9273808817854ff35a2c608c427930a2a4f624ded
MD5 d4b12155d84ae821b3b33cdd1f2dd09f
BLAKE2b-256 0d29fe0059abc5b58a64333b20f74d0400038e0622acde51471ee50a096213c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrx_batch-0.2.30-py3-none-any.whl:

Publisher: publish-package.yml on AI-Matrix-Engine/aidream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.34

2 files

0.2.33

2 files

0.2.32

2 files

0.2.31

2 files

This release

0.2.30 This release

2 files

0.2.29

2 files

0.2.28

2 files

0.2.27

2 files

0.2.26

2 files

0.2.25

2 files

0.2.24

2 files

0.2.23

2 files

0.2.22

2 files

0.2.21

2 files

0.2.20

2 files

0.2.19

2 files

0.2.18

2 files

0.2.17

2 files

0.2.16

2 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page