An agent decides it needs a database to complete its task
It creates one simply by generating a unique ID
The agent then creates the schema for the tables it needs
The database is stored as a file so no need to manage compute.
Each database is isolated and can be reused, downloaded, deleted, etc.
Upload or sync any number of exiting databases
AgentDB is also an MCP server
Agents can then use databases as context
import { DatabaseService } from "@agentdb/sdk";
import fs from "fs";
import "dotenv/config";
const agentdb = new DatabaseService("https://api.agentdb.dev", process.env.AGENTDB_API_KEY, true);
// Generate a new UUID for the database token
const newDatabaseToken = crypto.randomUUID();
console.log(`Generated new database token: ${newDatabaseToken}`);
const connection = agentdb.connect(newDatabaseToken, "users_db", "sqlite");
const main = async () => {
try {
console.log("Creating users table...");
// Create the users table
await connection.execute({
sql: `CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
age INTEGER,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)`
});
console.log("Populating users table with sample data...");
// Insert sample data
const sampleUsers = [
{ name: "Alice Johnson", email: "alice@example.com", age: 28 },
{ name: "Bob Smith", email: "bob@example.com", age: 34 },
{ name: "Carol Davis", email: "carol@example.com", age: 25 },
{ name: "David Wilson", email: "david@example.com", age: 42 },
{ name: "Eve Brown", email: "eve@example.com", age: 31 }
];
for (const user of sampleUsers) {
await connection.execute({
sql: "INSERT INTO users (name, email, age) VALUES (?, ?, ?)",
params: [user.name, user.email, user.age]
});
}
console.log("Querying all users from the database...");
// Query all users
const allUsers = await connection.execute({
sql: "SELECT * FROM users ORDER BY created_at"
});
console.log("All users:");
console.log(JSON.stringify(allUsers, null, 2));
console.log("Querying users older than 30...");
// Query users with a condition
const olderUsers = await connection.execute({
sql: "SELECT name, email, age FROM users WHERE age > ? ORDER BY age DESC",
params: [30]
});
console.log("Users older than 30:");
console.log(JSON.stringify(olderUsers, null, 2));
// Download the sqlite database
const download = await agentdb.getDownloadUrl(newDatabaseToken, "users_db", "sqlite");
const database = await fetch(download.downloadUrl).then((res) => res.arrayBuffer());
// Write the database to a file using node
fs.writeFileSync(download.fileName, Buffer.from(database));
console.log("Database operations completed successfully!");
} catch (error) {
console.error("Error during database operations:", error);
}
};
main();
Built-in vector search with sqlite-vec extension. Store embeddings, perform semantic search, and build RAG systems.
Maintain conversation state, user preferences, and context across sessions. Each conversation gets isolated storage.
Databases are ready instantly. Serverless architecture scales from zero to millions of requests.
| Database as Service | |
---|---|---|
Provisioning | Instantly allocate 1 or 1,000,000 databases without setup or configuration, just a unique ID. | Manual setup process involving database creation, user management, certificate issuance, and network or firewall configuration. |
Configuration & management | Batteries included. Connect as many clients as needed to as many databases as required, all over HTTP. Vector search for LLMs works out of the box. | Need to install and manage SQL extensions, configure appropriate measures like row-level security, and preallocate capacity to handle your clients. |
Cost | Pay only for data stored and queries executed, with no server or configuration costs. | Manual scaling requires forecasting usage ahead of time and knowledge of provider-specific tiers to find optimal price point. If underutilized you are billed for idle compute or if overutilized your performance is harmed. |
Portability | Download any database as a single file that can be run anywhere, instantly. | Exporting requires complex scripts or full database dumps, often at the expense of performance or uptime. Must spin up an entire database server to make use of the data. |
Data provenance | True tenant isolation, user data is separated at the filesystem level; malicious queries cannot cross user boundaries. | Unified database makes finding and acting on data regulation more complex. Security holes risk widespread data breaches. |
$0
$29/month
CUSTOM