Skip to main content

Batch Operations

ZeroDB batch endpoints let you execute multiple operations in a single request — reducing round-trips and improving throughput for bulk ingestion, migration, and agent pipelines.

Batch Query

Execute up to 50 table queries in one call:

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/batch/query \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"operations": [
{
"table": "agents",
"filters": {"status": "active"},
"limit": 10
},
{
"table": "sessions",
"filters": {"user_id": "usr-123"},
"limit": 5
}
],
"parallel": true,
"stop_on_error": false
}'

Batch Memory Upsert

Insert or update up to 500 memory records:

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/memory/batch/upsert \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"records": [
{
"content": "User prefers concise responses",
"memory_type": "semantic",
"importance": 0.8,
"tags": ["preference", "communication"]
},
{
"content": "Project uses FastAPI + SQLAlchemy",
"memory_type": "semantic",
"importance": 0.9,
"tags": ["tech-stack"]
}
]
}'

Batch Memory Delete

Delete up to 500 memory records by ID:

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/memory/batch/delete \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"ids": [
"mem-abc123",
"mem-def456",
"mem-ghi789"
]
}'

Batch Memory Update

Partial-update up to 500 memory records:

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/memory/batch/update \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"updates": [
{
"id": "mem-abc123",
"importance": 0.95,
"tags": ["preference", "high-priority"]
}
]
}'

Batch Vector Upsert

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/vectors/upsert-batch \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"vectors": [
{
"id": "vec-001",
"vector_embedding": [0.021, -0.043, 0.118],
"namespace": "documents",
"metadata": {"source": "upload", "doc_id": "doc-42"}
}
]
}'

Batch Event Publish

Publish up to 100 events in one request:

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/events/batch \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"topic": "agent.task.completed",
"event_payload": {"task_id": "task-001", "duration_ms": 1200}
},
{
"topic": "agent.task.completed",
"event_payload": {"task_id": "task-002", "duration_ms": 850}
}
]
}'

Batch RLHF Interactions

Log up to 1,000 RLHF interactions at once:

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/rlhf/interactions/batch \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"interactions": [
{
"prompt": "Explain async/await",
"response": "Async/await is a syntax for non-blocking I/O...",
"metadata": {"model": "qwen-coder-32b"}
},
{
"prompt": "What is a decorator in Python?",
"response": "A decorator wraps a function to extend its behavior...",
"metadata": {"model": "qwen-coder-32b"}
}
]
}'

Python SDK

import requests

API_KEY = "your-api-key"
PROJECT_ID = "your-project-id"
BASE = f"https://api.ainative.studio/api/v1/projects/{PROJECT_ID}/database"
headers = {"x-api-key": API_KEY, "Content-Type": "application/json"}

# Batch upsert memory
r = requests.post(f"{BASE}/memory/batch/upsert", headers=headers, json={
"records": [
{"content": f"Fact #{i}", "memory_type": "semantic", "importance": 0.7}
for i in range(100)
]
})
print(f"Upserted: {r.json()['inserted']} records")

# Batch publish events
r = requests.post(f"{BASE}/events/batch", headers=headers, json={
"events": [
{"topic": "user.action", "event_payload": {"action": "click", "item": f"item-{i}"}}
for i in range(50)
]
})
print(f"Published: {r.json()['published']} events")

Limits

OperationMax per batch
Batch query50 operations
Memory upsert500 records
Memory delete500 IDs
Memory update500 records
Vector upsertNo fixed limit (per vector store capacity)
Event publish100 events
RLHF interactions1,000 interactions

Endpoints

MethodPathDescription
POST/database/batch/queryExecute batch table queries (parallel optional)
POST/database/memory/batch/upsertBatch insert/update memory records
POST/database/memory/batch/deleteBatch delete memory by ID list
POST/database/memory/batch/updateBatch partial-update memory records
POST/database/vectors/upsert-batchBatch upsert vectors
POST/database/events/batchBatch publish events
POST/database/rlhf/interactions/batchBatch log RLHF interactions