Step 1: Obtain API key
Create a free account and generate an API key from the dashboard. The free tier gives you 5,000 queries per day. No credit card required.
Set your API key as an environment variable:
export LASERDATA_API_KEY="lsd_your_api_key_here"
Step 2: Install the SDK
LaserData offers Python and TypeScript SDKs. Use the SDK that matches your agent's runtime.
# Python
pip install laserdata
# TypeScript / Node.js
npm install laserdata
Step 3: Connect your agent
Initialize the client and write a context object. It reads LASERDATA_API_KEY automatically, or you can pass the key explicitly.
from laserdata import LaserDataClient
client = LaserDataClient() # reads LASERDATA_API_KEY from env
# Write context for a session
client.store(
namespace="my-agent",
key="session:abc123",
data={
"step": 1,
"task": "research",
"started_at": "2026-08-01T10:00:00Z"
}
)
# Read it back
ctx = client.get("my-agent", "session:abc123")
print(ctx)
# {"step": 1, "task": "research", "started_at": "2026-08-01T10:00:00Z"}
Step 4: Run a query
Run a filtered scan with client.query(). Most workloads return in under 3ms.
# Find all sessions in step 2 or higher
results = client.query(
namespace="my-agent",
filter={"step__gte": 2},
order_by="-step",
limit=20
)
for item in results.items:
print(item.key, item.data)
Step 5: Subscribe to events
Use client.stream() to receive write events as they occur. It uses a persistent connection, so polling is not required.
import asyncio
from laserdata import AsyncLaserDataClient
async def watch_sessions():
client = AsyncLaserDataClient()
async for event in client.stream("my-agent"):
print(event.type, event.key, event.data)
# type: "write" | "delete"
# arrives <1ms after the originating write completes
asyncio.run(watch_sessions())
Namespaces
A namespace is an isolated key-value space in your project. Use one per agent type or session for hard isolation. A namespace is created implicitly on its first write, with no schema required.
research-agent. Colons are also allowed for hierarchical names, such as session:abc123.