Skip to main content

matrx-api

The Python client of every AI Matrx server. Sister of the TypeScript @ai-matrx/api: both are GENERATED from the same language-neutral server contract (aidream/api-contract/), so every operation, deployment route, auth tier, org rule and stream kind agrees across languages.

Depends on httpx only. Never imports aidream, never reads env vars: the host injects credentials, the organization and base URLs.

from matrx_api import MatrxApi, UserCredential
from matrx_api.generated import files

async with MatrxApi(credentials=lambda: UserCredential(token()), organization_id=org_id,
                    base_urls={"aidream": "http://localhost:8000"}) as api:
    meta = await files.get_file(api, path={"file_id": fid})
    async for frame in await some_domain.some_ndjson_op(api, body={...}):   # NDJSON -> parsed dicts
        ...

Behaviours: credentials on every call (user / guest / api_key / service / scoped, re-read per call); X-Organization-Id per the operation's org rule (required + missing -> OrganizationContextError before the wire; exempt never sends one); unique X-Request-Id; GET/HEAD retry with backoff on network failure, writes never; one MatrxApiError(status, code, message); NDJSON/SSE/bytes streams as async iterators (*_or_json operations return JsonOrStream).

Per-schema types: every generated domain module exports the contract's request/response schemas as TypedDicts (files.TYPES) and annotates body= / the return with them. route_prefix= (a string for every deployment, or {deployment: prefix}) is prepended to every path for callers that mount under a prefix. Installs on Python >=3.11.

Regenerate

python packages/matrx-api/scripts/generate.py          # after the contract changes
python packages/matrx-api/scripts/generate.py --check  # exit 1 on drift (also run by the tests)

Writes matrx_api/generated/<domain>.py (one module per x-matrx-domain) and matrx_api/deployments.py (CONTRACT_SHA256, default base URLs). RED (exit 1) on a missing/unknown x-matrx-* tag, an operation no deployment serves, or a domain-module collision. Never edit generated files.

Test

uv run pytest packages/matrx-api/tests

Metadata

Release files for matrx-api 0.1.10

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-api 0.1.10
File Size Uploaded
matrx_api-0.1.10.tar.gz 471.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matrx-api 0.1.10
File Interpreter ABI Platform
matrx_api-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 945.1 kB

Release files / matrx_api-0.1.10.tar.gz

Download URL matrx_api-0.1.10.tar.gz
Size 471.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c60c26988998aeec4fa8945ad1697656f5bca8cfe5e7974a4dfaa3e197894273
BLAKE2b-256 checksum
How to use checksums
693715ef2201fdee94705edd2d489a06b35287fba4f1c26bfb72bb7f5a434628
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 Oct 18, 2026.

Transparency log

Release files / matrx_api-0.1.10-py3-none-any.whl

Download URL matrx_api-0.1.10-py3-none-any.whl
Size 473.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82539f2c43e53eb769c4e848fbd146c844611c68293efc1812f0b5fe35ee1d20
BLAKE2b-256 checksum
How to use checksums
7995cd78c24ef1959779468e0ebd3173cd973cf8aeae8e9ce1aeac21be1e47a8
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 Oct 18, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.11

2 release files

This release

0.1.10 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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