Arc Labs
BrainDocsPricing
GitHubSign inGet Started
LearnComparisons

Open Source to Cloud Upgrade Guide

By Arc Labs Research·May 13, 2026·5 min read
TL;DR

Upgrade from Brain open-source to Managed Cloud in 3 steps: put your API key and edge URL in your own environment, swap the client you construct, keep every verb name the same. The encode/recall/forget surface is identical on both tiers.

The Problem: Outgrowing Open Source

Brain open-source is great for development and early production, but at scale you hit:

  • Operational overhead: You manage upgrades, backups, scaling
  • Availability SLAs: No guarantees; downtime = your agent downtime
  • Multi-tenant isolation: If running multiple agents, they share compute
  • Compliance: You handle GDPR, SOC 2, data residency

Brain Managed Cloud is a drop-in replacement:

  • Zero downtime: Automatic failover, geo-redundancy
  • Compliance included: GDPR-ready, SOC 2, data residency options
  • Auto-scaling: Handles traffic spikes without config
  • Expert operations: Let us manage upgrades, backups, performance tuning

Best part: Your code doesn't change. Same API, same behavior, same queries—just point to the cloud.

The 3 Steps

Step 1: Set Environment Variables

Open source dials a host and port over TCP; cloud posts to an edge URL over HTTP. Both require an API key — there is no anonymous mode on either tier.

The SDKs read no environment variables of their own — these are your application's names, and your code passes their values to the client constructor.

# Before (self-hosted): the wire client dials the server over TCP
export BRAIN_HOST="127.0.0.1"
export BRAIN_PORT="9090"
export BRAIN_API_KEY="brain_...your_api_key..."

# After (hosted edge): the HTTP client posts to an edge URL
export BRAIN_API_KEY="brain_...your_api_key..."
export BRAIN_EDGE_URL="https://brain-edge.internal.example"

Get your BRAIN_API_KEY from the Brain Cloud dashboard. There is no public hosted endpoint yet, so until there is, BRAIN_EDGE_URL points at a brain-edge you run — http://127.0.0.1:8080 for one on your own machine, which is also what the client defaults to when you omit it.

Step 2: Update Initialization

Python:

Before (open source):

import os
from brain_db_sdk import Auth, BrainClient

client = BrainClient.connect(
    os.environ["BRAIN_HOST"], int(os.environ["BRAIN_PORT"]),
    Auth.token(os.environ["BRAIN_API_KEY"].encode()),
)

After (cloud):

import os
from brain_db_sdk import BrainHttpClient

# base_url defaults to http://127.0.0.1:8080 — point it at your edge.
brain = BrainHttpClient(
    os.environ["BRAIN_API_KEY"], base_url=os.environ["BRAIN_EDGE_URL"],
)

Read the variables yourself, as above: the SDK never reads the environment, so there is no implicit-config form of this constructor.

TypeScript:

Before (open source):

import { BrainClient } from "@brain-db/sdk";

const auth = { kind: "token", token: new TextEncoder().encode(process.env.BRAIN_API_KEY!) };
const client = await BrainClient.connect("127.0.0.1", 9090, { auth });

After (cloud):

// Import the HTTP tier from the /http subpath. The package root also pulls
// the wire client, which imports node:net and node:crypto — fatal on
// Workers, Deno, Bun and the Next.js Edge runtime.
import { BrainHttpClient } from "@brain-db/sdk/http";

const brain = new BrainHttpClient({
  apiKey: process.env.BRAIN_API_KEY!,
  baseUrl: process.env.BRAIN_EDGE_URL, // omit for http://127.0.0.1:8080
});

Field names are camelCase in and out — maxResults, never max_results. A snake_case key is an excess property the client drops, so the edge silently applies its own default instead.

Step 3: Deploy & Test

The verb names are the same on both tiers — encode, recall, forget, memory_list — so only the client you constructed above changes. Your space and namespace come from the API key; neither is a client argument.

# Same verbs on the hosted edge as on a self-hosted server
brain.encode(text="User prefers coffee at 8am")

answer = brain.recall(query="What does the user like?", max_results=5)
for memory in answer.memories:
    print(memory.text)

Deploy your updated config and it just works.

Environment Variables

None of these are read by the SDK. They are the names used throughout this guide for values your own code passes to the client constructor.

VariableRequiredExamplePassed as
BRAIN_API_KEYYesbrain_1a2b3c4d5e...apiKey / api_key — get it from the Brain Cloud dashboard
BRAIN_EDGE_URLNohttp://127.0.0.1:8080baseUrl / base_url; the client defaults to http://127.0.0.1:8080
—No30000timeoutMs (TypeScript, default 30000) / timeout seconds (Python, default 30.0)

Backward Compatibility Guarantee

✓ The verb surface stays the same. encode(), recall(), forget(), memory_list() and the typed-graph verbs carry the same names and field names on both tiers.

✓ Same response format. Brain Cloud returns identical JSON to open-source.

✓ One error type. The HTTP tier raises BrainHttpError, carrying status, code, message and, on a 422, per-field errors.

✓ Rollback is safe. If you need to revert, construct the wire BrainClient against your own host and port again.

Performance Expectations

MetricOpen Source (Local)Cloud
P50 latency10–20ms50–100ms (includes network RTT)
P99 latency50–100ms150–200ms
ThroughputLimited by single machineAuto-scales to 10K+ req/s
AvailabilityDependent on your infra99.9% SLA

Cloud adds network round-trip time but gains reliability and scale. For agent loops, 50–100ms is acceptable (agents don't require <10ms).

Cost Comparison: OSS vs Cloud

ModelCostBest For
Open Source$0 software + infra costDevelopment, single-machine deployments, full control
Cloud0.001/vectorstored+0.001/vector stored + 0.001/vectorstored+0.0005/retrievalMulti-team, compliance-required, auto-scaling needs

Example for 100 agents with 5K memories each = 500K vectors:

  • OSS on EC2 (t3.medium): $20/month infra + your ops time
  • Cloud: 500/monthfor500Kvectors+500/month for 500K vectors + 500/monthfor500Kvectors+100/month retrievals (1K/day)

Cloud wins if you have multiple agents or need compliance/availability.

Implementation Checklist

  • Create Brain Cloud account (or request API key if provided)
  • Copy your BRAIN_API_KEY from the dashboard
  • Set environment variables: BRAIN_API_KEY and BRAIN_EDGE_URL
  • Swap BrainClient for BrainHttpClient and pass the key and edge URL to it
  • Test: store a memory, retrieve it, verify content matches
  • Deploy to staging; run agent for 1 hour, monitor latency
  • Verify: latency is acceptable (P99 <200ms), error rates are <0.1%
  • Deploy to production

Troubleshooting

Authentication error ("401 Unauthorized")

  • Verify BRAIN_API_KEY is correct and not expired
  • Check that it carries no trailing newline — the client rejects control characters in a key
  • Check dashboard: key might be revoked

Connection timeout

  • Confirm BRAIN_EDGE_URL is the https:// scheme, not http://, for a remote edge
  • Check firewall: outbound HTTPS to your edge host should be allowed
  • Test identity and reachability in one call: curl -H "Authorization: Bearer $BRAIN_API_KEY" "$BRAIN_EDGE_URL/v1/whoami"

Latency spike

  • Cloud P99 is 150–200ms; if you see >300ms, contact support
  • Check network conditions; local ISP issues can add 100ms+

Migration rollback

  • Point your code back at the wire client on your own host and port to revert to open-source
  • Data is not synced; export from cloud if needed

Data Migration (Optional)

If you want to export memories from open-source before switching:

import json
import os
from brain_db_sdk import BrainHttpClient

# Self-hosted edge in front of your open-source server
brain_oss = BrainHttpClient(os.environ["BRAIN_API_KEY"], base_url="http://127.0.0.1:8080")

# Export: page through memory_list until there is no next cursor.
# The key already scopes the read to one space — there is no space argument.
all_memories = []
cursor = None
while True:
    page = brain_oss.memory_list(limit=500, cursor=cursor)
    all_memories.extend({"text": item.text} for item in page.items)
    cursor = page.next_cursor
    if cursor is None:
        break

# Save
with open("memories_export.json", "w") as f:
    json.dump(all_memories, f)

# Then import to Cloud
brain_cloud = BrainHttpClient(os.environ["BRAIN_API_KEY"], base_url=os.environ["BRAIN_EDGE_URL"])

for memory in all_memories:
    brain_cloud.encode(text=memory["text"])

Next Steps

  • Learn pricing: Check Cost Optimization for Agent Memory
  • Multi-team setup: See Embedded vs Cloud Decision for deployment patterns
  • Scale your agents: Read Production Checklist for monitoring and observability

Related reading

  • GuidesCost Optimization for Agent Memory
  • GuidesSelf-Hosted vs Managed Cloud
PreviousMigrating from Pinecone to Brain

Updates from the lab.

Engineering notes, research drops, occasional product updates. Roughly monthly.

Arc Labs

Cognitive infrastructure for AI agents. Open core in Rust. Composable primitives you own.

GitHubX / TwitterDiscussions

Brain

  • Memory Layer
  • Documentation
  • Pricing
  • Changelog
  • Status

Developers

  • Start here
  • TypeScript SDK
  • Python SDK
  • Rust SDK
  • MCP Server

Company

  • About
  • Careers
  • Blog
  • Security
  • Contact
Encode"Priya lives in Berlin."mem_7f3a · storedRecall"where does Priya live?"→ BerlinSupersede"Priya moved to Lisbon."mem_9c21 ⊃ mem_7f3aBerlin→ LisbonARC LABSARC LABSARC LABS
© 2026 ARC LABS · BANGALOREPrivacyTermsDPAApache 2.0