Migrate from a self-hosted AgentLens instance to AgentLens Cloud. The process takes about 5 minutes per agent — all your instrumentation code stays the same.
| Aspect | Self-Hosted | Cloud |
|---|---|---|
| Server | You run @agentlensai/server |
Managed at api.agentlens.ai |
| Init parameter | url="http://localhost:3400" |
cloud=True |
| API key format | als_... (local) |
als_cloud_... (cloud) |
| Database | Local SQLite | Managed Postgres (multi-tenant) |
| Dashboard | http://localhost:3400 |
https://app.agentlens.ai |
Everything about your instrumentation is unchanged:
- ✅ All auto-instrumented providers (OpenAI, Anthropic, LiteLLM, Bedrock, Vertex, Gemini, Mistral, Cohere, Ollama)
- ✅ MCP server integration (Claude Desktop, Cursor)
- ✅ All SDK methods (
get_sessions,get_llm_analytics,recall,learn, etc.) - ✅ Event types, session lifecycle, hash chain verification
- ✅ Health scores, cost optimization, benchmarks, guardrails
- ✅ Agent memory (recall, lessons, reflect, context)
- ✅ Framework plugins (LangChain, CrewAI, AutoGen, Semantic Kernel)
- ✅ Redaction (
redact=True) and privacy controls
Go to https://app.agentlens.ai and create an account. See the Cloud Setup Guide for details.
In the dashboard: Settings → API Keys → Create API Key. Copy the als_cloud_... key.
Cloud mode requires agentlensai >= 0.11.0:
pip install --upgrade agentlensai
# or
npm install @agentlensai/sdk@latestBefore (self-hosted):
import agentlensai
agentlensai.init(
url="http://localhost:3400",
api_key="als_your_local_key",
agent_id="my-agent",
)After (cloud):
import agentlensai
agentlensai.init(
cloud=True,
api_key="als_cloud_your_key_here",
agent_id="my-agent",
)That's it. One parameter changes (url → cloud=True), plus the new API key. Everything else stays identical.
TypeScript — Before:
const client = new AgentLensClient({
baseUrl: 'http://localhost:3400',
apiKey: 'als_your_local_key',
});TypeScript — After:
const client = new AgentLensClient({
cloud: true,
apiKey: 'als_cloud_your_key_here',
});Before:
export AGENTLENS_SERVER_URL=http://localhost:3400
export AGENTLENS_API_KEY=als_your_local_keyAfter:
export AGENTLENS_CLOUD=true
export AGENTLENS_API_KEY=als_cloud_your_key_here
# Remove AGENTLENS_SERVER_URL — not needed with cloud=True
unset AGENTLENS_SERVER_URLBefore (Claude Desktop / Cursor):
{
"mcpServers": {
"agentlens": {
"command": "npx",
"args": ["@agentlensai/mcp"],
"env": {
"AGENTLENS_API_URL": "http://localhost:3400",
"AGENTLENS_API_KEY": "als_your_local_key"
}
}
}
}After:
{
"mcpServers": {
"agentlens": {
"command": "npx",
"args": ["@agentlensai/mcp"],
"env": {
"AGENTLENS_CLOUD": "true",
"AGENTLENS_API_KEY": "als_cloud_your_key_here"
}
}
}
}Run your agent and confirm data appears in the cloud dashboard:
import agentlensai
agentlensai.init(cloud=True, api_key="als_cloud_your_key_here", agent_id="my-agent")
# Trigger one LLM call
import openai
client = openai.OpenAI()
client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Migration test"}],
)
agentlensai.shutdown()
print("Check https://app.agentlens.ai — you should see the session.")Or use the CLI:
npx @agentlensai/cli cloud sessions --limit 1To export data from your self-hosted instance and import into cloud:
# Export from self-hosted
npx @agentlensai/cli export --output agentlens-export.json
# Import to cloud
npx @agentlensai/cli cloud import --file agentlens-export.json --api-key als_cloud_your_key_hereNote: The import preserves session IDs, event data, and hash chains. Lessons and memory are included.
If you need to switch back, reverse the changes:
- Revert init call:
agentlensai.init(
url="http://localhost:3400",
api_key="als_your_local_key",
agent_id="my-agent",
)- Revert environment variables:
export AGENTLENS_SERVER_URL=http://localhost:3400
export AGENTLENS_API_KEY=als_your_local_key
unset AGENTLENS_CLOUD- Restart your self-hosted server:
npx @agentlensai/server- Revert MCP config (if applicable) — restore the
AGENTLENS_API_URLentry.
Your self-hosted instance and data remain intact throughout. Cloud and self-hosted can even run side-by-side during a transition period if you keep both API keys active.
Can I run cloud and self-hosted simultaneously?
Yes. Use different agent_id values or separate init calls. This is useful for a gradual migration.
Is my data encrypted in transit?
Yes. All communication with api.agentlens.ai uses TLS 1.3.
What about data residency? AgentLens Cloud runs in US regions by default. Contact us for EU or other region requirements.
Do I still need the server package?
No. With cloud=True, you don't need to run @agentlensai/server. You only need the SDK (agentlensai for Python or @agentlensai/sdk for TypeScript).
- Cloud Setup Guide — full setup walkthrough
- API Reference — REST API documentation