Client Guides
OpenAI Agents SDK
Give agents built with the OpenAI Agents SDK a HyperMemory memory
The OpenAI Agents SDK connects to remote MCP servers natively, so HyperMemory’s tools plug straight in.
Setup
pip install openai-agents
export HYPERMEMORY_API_KEY=hm_YOUR_KEY
Create keys under API Keys in the dashboard.
Connect the MCP server
import asyncio
import os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
async def main():
async with MCPServerStreamableHttp(
name="HyperMemory",
params={
"url": "https://api.hypermemory.io/mcp",
"headers": {"Authorization": f"Bearer {os.environ['HYPERMEMORY_API_KEY']}"},
"timeout": 30,
},
cache_tools_list=True,
) as hypermemory:
agent = Agent(
name="Assistant",
instructions=(
"Before answering, call hm_recall with the user's words. "
"When the user tells you something worth keeping, check with hm_recall, "
"then save it with hm_store (or hm_update if it already exists), "
"linked to related memories."
),
mcp_servers=[hypermemory],
)
result = await Runner.run(agent, "When are we launching checkout?")
print(result.final_output)
asyncio.run(main())
Use the full protocol
For the complete HyperMemory instructions, fetch the skill once and use it as the agent’s instructions:
skill = await hypermemory.call_tool("hm_skill", {"action": "get", "variant": "general"})
Without MCP
With the plain Chat Completions or Responses API, define function tools for the HyperMemory tools you need and call the REST API when the model uses one. Each tool’s page lists its parameters; tools/list returns ready-made JSON schemas you can reuse.
import httpx, os
hm = httpx.Client(
base_url="https://api.hypermemory.io/api/v1/memory",
headers={"Authorization": f"Bearer {os.environ['HYPERMEMORY_API_KEY']}"},
)
def run_tool(name: str, args: dict) -> dict:
route = {"hm_recall": "/recall", "hm_store": "/store", "hm_update": "/update"}[name]
return hm.post(route, json=args).json()
Report token usage
To see these agents in token usage, call hm_tokens after each run with the exact counts from result.context_wrapper.usage and measurement_quality: "client_exact".