Skip to content

Pydantic AI

Add Suprflo long-term memory to Pydantic AI agents. Ships in the Python SDK.

Install

bash
pip install "suprflo[pydantic-ai]"

What you get

All built on the Python SDK MemoryClient:

  • SuprfloDeps — an agent dependency carrying the client and the user_id the tools operate on.
  • save_memory / search_memory — tool functions that read those deps off the RunContext.
  • memory_tools() — both wrapped as Pydantic AI Tools.

Tools for an agent

python
from pydantic_ai import Agent
from suprflo import MemoryClient
from suprflo.integrations.pydantic_ai import SuprfloDeps, memory_tools

client = MemoryClient(api_key="YOUR_API_KEY")
agent = Agent(
    "openai:gpt-4o",
    deps_type=SuprfloDeps,
    tools=memory_tools(),
)

result = await agent.run(
    "What do you know about my hobbies?",
    deps=SuprfloDeps(client=client, user_id="alice", top_k=5),
)

Because the subject arrives through deps rather than a closure, one agent definition serves every user — pass different SuprfloDeps per run.

Tools only

Pydantic AI has no memory or history-store plugin contract to implement — tools plus deps are its real extension points, and that is the whole integration surface. There's deliberately no SuprfloMemory class here; there'd be nothing for it to plug into.

If pydantic-ai isn't installed, importing this module raises a clear ImportError telling you to pip install "suprflo[pydantic-ai]".

The memory layer for AI agents.