OpenAI-Compatible Agents
Any agent that can make HTTP requests can use Synapse Layer. This guide shows the REST API pattern for adding encrypted persistent memory to OpenAI-compatible agents, custom LLM wrappers, or any HTTP-capable system.
Overview
Not every agent framework has a dedicated Synapse Layer integration. For GPT-based agents, custom LLM wrappers, or any system that can make HTTP calls, the REST API provides full access to the Cognitive Security Pipeline — PII sanitization, intent classification, differential privacy, and AES-256-GCM encryption.
Note
Store Memory
Store a memory via the REST API. The content is automatically processed through the full security pipeline before persistence:
curl -X POST https://your-forge-url/api/v1/memory/commit \
-H "Content-Type: application/json" \
-H "x-connect-token: YOUR_TOKEN" \
-d '{
"content": "User prefers dark mode and TypeScript.",
"agentId": "my-agent",
"metadata": {
"source": "onboarding",
"importance": 0.8
}
}'Python equivalent using httpx:
import httpx
response = httpx.post(
"https://your-forge-url/api/v1/memory/commit",
headers={
"Content-Type": "application/json",
"x-connect-token": "YOUR_TOKEN",
},
json={
"content": "User prefers dark mode and TypeScript.",
"agentId": "my-agent",
},
)
result = response.json()
print(f"Memory ID: {result['memoryId']}")
print(f"Trust Quotient: {result['trustQuotient']}")Recall Memory
curl -X POST https://your-forge-url/api/v1/sdk/recall \
-H "Content-Type: application/json" \
-H "x-connect-token: YOUR_TOKEN" \
-d '{
"query": "user preferences",
"agentId": "my-agent",
"topK": 5
}'The response includes matched memories with content, trust quotient scores, and metadata for each result.
Function Calling Pattern
For OpenAI function-calling agents, define Synapse Layer as a tool:
tools = [
{
"type": "function",
"function": {
"name": "store_memory",
"description": "Store information for later recall. Content is encrypted and PII-sanitized.",
"parameters": {
"type": "object",
"properties": {
"content": {
"type": "string",
"description": "The information to remember"
}
},
"required": ["content"]
}
}
},
{
"type": "function",
"function": {
"name": "recall_memory",
"description": "Search stored memories by semantic similarity.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "What to search for"
}
},
"required": ["query"]
}
}
}
]
# When the agent calls a tool, route to the REST API:
def handle_tool_call(name, args):
import httpx
base = "https://your-forge-url"
headers = {"x-connect-token": "YOUR_TOKEN", "Content-Type": "application/json"}
if name == "store_memory":
r = httpx.post(f"{base}/api/v1/memory/commit",
headers=headers,
json={"content": args["content"], "agentId": "my-agent"})
return r.json()
elif name == "recall_memory":
r = httpx.post(f"{base}/api/v1/sdk/recall",
headers=headers,
json={"query": args["query"], "agentId": "my-agent"})
return r.json()Other Frameworks
The same REST API pattern works with any agent framework. For dedicated integrations with richer features, see: