Docs · Integrations

Five patterns, every agent.

1 · One-liner SDK

from reflex.plug import openai_client  # or anthropic_client
chat = openai_client()  # REFLEX_URL env → your server
r = chat.chat.completions.create(model="mock/mock-echo",
    messages=[{"role": "user", "content": "Hi"}], user="u1")

Raw client: from reflex import Client; Client("http://localhost:8000").ask(...)

2 · LangGraph node

from reflex.contrib.langgraph import MemflexNode  # (ReflexNode alias kept)
graph.add_node("respond", MemflexNode(llm="mock/mock-echo"))

3 · Tool-agents (plan once, serve forever)

res = rx.ask(user_id=u, message=q, llm=llm)
if res.source.startswith("reflex"):
    return res.answer                 # zero tools, zero LLM
facts = run_tools(plan(llm, q))       # System 2, miss only
composed = " | ".join(facts)
rx.save_reflex(user_id=u, message=q, answer=composed)  # upsert, no dupes

4 · Guardrail gate (typed + confident only)

res = rx.ask(..., extract_structured=True,
             output_schema={"refund_status": "str"})
if res.source.startswith("reflex") and res.confidence >= 0.9:
    auto_approve(res)   # calibrated safe band
else:
    escalate_to_human(res)

5 · Voice agents (LiveKit)

Memflex speaks OpenAI-protocol SSE, so LiveKit's OpenAI plugin connects with a base_url — no custom integration. Repeats stream from memory in milliseconds (ideal for turn-taking); novel turns fall through to your upstream model. Pass the caller identity as user for per-caller memory isolation.

from livekit.plugins import openai
session = AgentSession(
    llm=openai.LLM(
        model="openai/gpt-4o-mini",  # upstream, used only on misses
        base_url="http://localhost:8000/v1",
        api_key="not-needed",  # or MEMFLEX_API_KEY
        user="caller-123",  # per-caller memory isolation
    ),
    # ... tts, stt, vad, turn_detection, etc.
)
import * as openai from '@livekit/agents-plugin-openai';
const session = new voice.AgentSession({
  llm: new openai.LLM({
    model: 'openai/gpt-4o-mini',
    baseURL: 'http://localhost:8000/v1',
    apiKey: 'not-needed',
    user: 'caller-123',
  }),
});

Limits, stated plainly: Chat Completions path only (no Realtime/Responses API yet); function tools forward on OpenAI-compatible models, other backends answer explicit 400; keep answers short for voice — the default system prompt already asks for concision.

Migrating from Mem0?

from reflex.compat import mem0  # basic add/search drop-in
db = mem0.MemoryClient(base_url="http://localhost:8000")