CortexDB Docs
Docs for CortexDB 0.12.8, the version running on CortexDB Cloud (api.cortexdb.ai).
Integrations

PydanticAI

Inject CortexDB memory into PydanticAI agents via dependencies.

PydanticAI passes CortexDB into an agent through its typed dependencies (deps).

Install

pip install cortexdbai[pydanticai]

Dependencies

from cortexdb import Cortex
from cortexdb.integrations.pydanticai import CortexDBDeps

client = Cortex(api_url="https://api-v1.cortexdb.ai", actor="user:alice",
                bearer=os.environ["CORTEX_TOKEN"])

deps = CortexDBDeps(client=client, scope="org:acme/user:alice")

agent = Agent("openai:gpt-4o", deps_type=CortexDBDeps)

@agent.tool
async def recall_memory(ctx, query: str) -> str:
    pack = ctx.deps.client.recall(scope=ctx.deps.scope, view="holistic",
                                  query=query, diagnostics="none")
    return pack.get("context_block", "")

See also

On this page