Unified multi-provider AI client, orchestration, and tool system for Python. One UnifiedAIClient that speaks to 12+ provider SDKs (OpenAI, Anthropic, Google, Groq, Cerebras, xAI, Together, ElevenLabs, Hugging Face, Cohere, Fireworks, Replicate) through a common UnifiedConfig / UnifiedMessage / UnifiedResponse contract, with streaming, tool calls, agents, and an orchestrator that runs a model until its task is complete.
Install
pip install matrx-ai
Python 3.13+ required. Depends on matrx-utils, matrx-connect, matrx-graph, plus the provider SDKs. Host applications inject their own ORM models at startup via matrx_ai.configure(...).
What's in the box
Unified client (UnifiedAIClient): one async interface over every supported provider; request translation + response normalization handled by per-provider adapters.
Tools (matrx_ai.tools): registry + built-in implementations (ctx_patch, ctx_create, shell, code, …). All host-specific integration points (ContextManifest, writeback persistence, test helpers) come in via configure().
Context (matrx_ai.context): re-exports AppContext + Emitter from matrx-connect.
Persistence (matrx_ai.db): Supabase-backed conversation/request storage. ORM models are host-injected.
matrx-ai is designed to be embedded in a larger application (like aidream) that supplies ORM models, settings, and context-object classes. It is also designed to run without any of that configuration — most features work on their own; the DB-dependent ones raise ExtNotConfiguredError at call time if the host didn't wire them up.
import matrx_ai
matrx_ai.configure(
db_models={"AiModel": AiModel, "CxConversation": CxConversation, ...},
db_bases={"CxConversationBase": CxConversationBase, ...},
db_instances={"guest_executions_manager": guest_manager},
db_extras={"ContentBlocksDTO": ContentBlocksDTO},
settings=settings,
get_supabase_client=get_async_supabase_client,
# Context-object model classes (used by ctx_patch / ctx_create tools)
context_object_cls=ContextObject,
context_object_type_cls=ContextObjectType,
context_source_cls=ContextSource,
persist_mode_cls=PersistMode,
context_manifest_cls=ContextManifest,
load_manifest_from_ctx=load_manifest_from_ctx,
schedule_context_writeback=schedule_writeback,
# …anything else the host wants to make available
)
This is the reference implementation of the "capability-within, injection-without" pattern used throughout the Matrx family — the package stores injected values in a module-level _ext registry; feature code retrieves them at call time via get_ext("…"). import matrx_ai always works in a minimal environment; only features that need a specific injection will raise if it's missing.
For a client host, get_jwt may be a synchronous or asynchronous zero-argument provider. matrx-ai resolves it at each authenticated server request and does not cache its result. Once a host configures that provider, a failure or missing token refuses the authenticated request instead of falling back to anonymous access. Without a provider, the public tool-catalog fetch remains unauthenticated.
Dependency posture
Hard deps: matrx-utils, matrx-connect, matrx-graph, plus the provider SDKs (Anthropic, OpenAI, Google GenAI, Groq, Cerebras, xAI, Together, Cohere, Fireworks, Replicate, Tiktoken) and core libs (pydantic, httpx, aiohttp, supabase, asyncpg, json-repair, numpy, rich).
matrx-ai does not depend on matrx-orm. The host app that embeds matrx-ai may use matrx-orm (aidream does), but matrx-ai itself accepts ORM model classes through configure(db_models=..., db_bases=..., ...) rather than importing them.
Replaces
The old root-level ai/ folder in the aidream monorepo. matrx-ai is now the canonical AI layer.
CLI utility and Python library for interacting with Large Language Models from organizations like OpenAI, Anthropic and Gemini plus local models installed on your own machine.