New in Public Preview – PostgreSQL Support and TiDB Cloud Filesystem

Trusted by

SOLUTIONS

Purpose-Built for Agentic Scale

Designed to keep branching, state, and transactional consistency together as agents operate across multiple tasks and sessions.

Instant Branching

Create isolated database environments in milliseconds for parallel tasks, agent sessions, and experimentation.


See how TiDB helped Manus

Durable Agent State

Persist memory, intermediate outputs, and workflow progress across long-running agent interactions. For working files that need to outlive a sandbox, explore TiDB Cloud Filesystem.


See how Dify solved this

Pay-as-You-Go with Granular Control

Only pay for what your agents actually use. TiDB’s per-agent cost tracking and Request Unit metering give you full visibility and zero provisioning waste — no matter how many sessions run concurrently.


Check pricing

CUSTOMERS

Proven at Scale

Leading AI innovators are solving scaling challenges with TiDB.

General-Purpose AI Agents

“TiDB’s elastic architecture enabled us to migrate in two weeks, supporting users and massive ‘Context Engineering’ workloads for viral success.”

AI App Development Platform

“We consolidated our entire AI backend into TiDB—letting our engineers focus on building agent features instead of managing database complexity.”

Autonomous Marketing Automation

“TiDB’s unified architecture enabled AI agents to access complete, real-time user context for autonomous marketing decisions.”

Conversational Business Intelligence

“Unified HTAP + Vector engine enabled hybrid queries combining semantic understanding with SQL precision for real-time conversational analytics.”

Real-Time Event Analytics

“Real-time architecture enabled storing and aggregating survey data on the fly, eliminating processing overhead.”

DEMOS

Build, Test and Scale Agent Systems

Explore practical examples, runnable demos, and developer resources for building stateful agent workflows on TiDB.

Python SDK for TiDB AI

pip install pytidb

Database Branching for Agents
Instant isolated environments for parallel agent execution.

 

Database Branching for Agents

Create isolated database environments in milliseconds so agents can test changes and explore parallel paths without affecting the original database.


// npm install digest-fetch@3.1.1
// Set TIDB_CLOUD_PUBLIC_KEY, TIDB_CLOUD_PRIVATE_KEY, and TIDB_CLUSTER_ID.
// Use API keys with permission to create branches on the selected cluster.
// Save as database-branching.mjs and run with Node.js.
import DigestClient from "digest-fetch";
import { randomUUID } from "node:crypto";
import { setTimeout as wait } from "node:timers/promises";

for (const key of [
  "TIDB_CLOUD_PUBLIC_KEY", "TIDB_CLOUD_PRIVATE_KEY", "TIDB_CLUSTER_ID",
]) {
  if (!process.env[key]) throw new Error(`Set ${key} first.`);
}
const client = new DigestClient(
  process.env.TIDB_CLOUD_PUBLIC_KEY,
  process.env.TIDB_CLOUD_PRIVATE_KEY
);
const base = "https://serverless.tidbapi.com/v1beta1";
const path = `/clusters/${encodeURIComponent(process.env.TIDB_CLUSTER_ID)}/branches`;

async function request(path, method = "GET", body) {
  const response = await client.fetch(`${base}${path}`, {
    method,
    headers: { "Content-Type": "application/json", Accept: "application/json" },
    body: body === undefined ? undefined : JSON.stringify(body),
    signal: AbortSignal.timeout(30000),
    redirect: "error",
  });
  if (!response.ok) throw new Error(`Branch API: HTTP ${response.status}`);
  return response.json();
}

let branch = await request(path, "POST", {
  displayName: `agent-test-${randomUUID().slice(0, 8)}`,
});
if (!branch.branchId) throw new Error("Branch API returned no branch ID.");
const branchId = branch.branchId;
console.log("Branch requested:", branchId);

const deadline = Date.now() + 5 * 60 * 1000;
while (branch.state !== "ACTIVE") {
  if (branch.state === "DELETED" || Date.now() >= deadline) {
    throw new Error(`Check branch ${branchId} in the console before retrying.`);
  }
  await wait(5000);
  branch = await request(`${path}/${encodeURIComponent(branchId)}`);
}
console.log("Branch ready:", branchId);
// Connect using this branch's credentials from the TiDB Cloud console.
// Delete this test branch in the console when your experiment is finished.

Persistent Agent State
Store intermediate outputs and long-running memory reliably.

Persistent Agent State

Persist agent memory, intermediate outputs, and workflow progress in TiDB. Keep code, files, and saved Git state available across sandboxes in TiDB Cloud Filesystem.


// npm install @tidbcloud/serverless@0.3.0
// Set TIDB_URL to a TiDB Cloud connection URL with a database selected.
// Save as persistent-agent-state.mjs and run with Node.js.
import { connect } from "@tidbcloud/serverless";
import { randomUUID } from "node:crypto";

if (!process.env.TIDB_URL) throw new Error("Set TIDB_URL first.");
const db = connect({ url: process.env.TIDB_URL });
await db.execute(`CREATE TABLE IF NOT EXISTS agent_memory_demo (
  agent_id VARCHAR(64) PRIMARY KEY,
  state JSON NOT NULL,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
)`);

async function saveAgentState(agentId, state) {
  await db.execute(
    `INSERT INTO agent_memory_demo (agent_id, state, updated_at)
     VALUES (?, ?, NOW())
     ON DUPLICATE KEY UPDATE state = VALUES(state), updated_at = NOW()`,
    [agentId, JSON.stringify(state)]
  );
}

async function restoreAgentState(agentId) {
  const [row] = await db.execute(
    "SELECT state FROM agent_memory_demo WHERE agent_id = ?",
    [agentId]
  );
  return row ? row.state : null; // JSON columns are already decoded.
}

const agentId = randomUUID(); // Keep this ID to resume the same agent later.
const previousState = (await restoreAgentState(agentId)) ?? {};
await saveAgentState(agentId, {
  ...previousState,
  step: "summarize",
  outputs: ["draft-1.md"],
  tokensUsed: 4210,
});
console.log("Agent ID:", agentId);
console.log("Restored state:", await restoreAgentState(agentId));

Concurrent Transactions for Agent Workflows
Maintain correctness across simultaneous actions.

 

Concurrent Transactions for Agent Workflows

Multiple agents can work in parallel. TiDB’s ACID transactions maintain consistency across concurrent database updates.


// npm install @tidbcloud/serverless@0.3.0
// Set TIDB_URL to a TiDB Cloud connection URL with a database selected.
// Save as concurrent-agent-transactions.mjs and run with Node.js.
import { connect } from "@tidbcloud/serverless";
import { randomUUID } from "node:crypto";

if (!process.env.TIDB_URL) throw new Error("Set TIDB_URL first.");
const db = connect({ url: process.env.TIDB_URL });
await db.execute(`CREATE TABLE IF NOT EXISTS agent_tasks_demo (
  id VARCHAR(64) PRIMARY KEY,
  status VARCHAR(20) NOT NULL,
  agent_id VARCHAR(64)
)`);

async function assignTask(taskId, agentId) {
  const tx = await db.begin(); // Each worker gets its own transaction.
  try {
    const [task] = await tx.execute(
      "SELECT status FROM agent_tasks_demo WHERE id = ? FOR UPDATE",
      [taskId]
    );
    if (!task || task.status !== "pending") {
      await tx.rollback();
      return { agentId, claimed: false };
    }
    await tx.execute(
      "UPDATE agent_tasks_demo SET status = ?, agent_id = ? WHERE id = ?",
      ["running", agentId, taskId]
    );
    await tx.commit();
    return { agentId, claimed: true };
  } catch (error) {
    await tx.rollback().catch(() => {});
    throw error;
  }
}

const taskId = randomUUID(); // Use a fresh task on every run.
await db.execute(
  "INSERT INTO agent_tasks_demo (id, status) VALUES (?, ?)",
  [taskId, "pending"]
);
console.log(await Promise.all([
  assignTask(taskId, "agent-A"),
  assignTask(taskId, "agent-B"),
])); // Exactly one agent claims the task; the other returns claimed: false.

Database Branching for Agents

Create isolated database environments in milliseconds so agents can test changes and explore parallel paths without affecting the original database.


// npm install digest-fetch@3.1.1
// Set TIDB_CLOUD_PUBLIC_KEY, TIDB_CLOUD_PRIVATE_KEY, and TIDB_CLUSTER_ID.
// Use API keys with permission to create branches on the selected cluster.
// Save as database-branching.mjs and run with Node.js.
import DigestClient from "digest-fetch";
import { randomUUID } from "node:crypto";
import { setTimeout as wait } from "node:timers/promises";

for (const key of [
  "TIDB_CLOUD_PUBLIC_KEY", "TIDB_CLOUD_PRIVATE_KEY", "TIDB_CLUSTER_ID",
]) {
  if (!process.env[key]) throw new Error(`Set ${key} first.`);
}
const client = new DigestClient(
  process.env.TIDB_CLOUD_PUBLIC_KEY,
  process.env.TIDB_CLOUD_PRIVATE_KEY
);
const base = "https://serverless.tidbapi.com/v1beta1";
const path = `/clusters/${encodeURIComponent(process.env.TIDB_CLUSTER_ID)}/branches`;

async function request(path, method = "GET", body) {
  const response = await client.fetch(`${base}${path}`, {
    method,
    headers: { "Content-Type": "application/json", Accept: "application/json" },
    body: body === undefined ? undefined : JSON.stringify(body),
    signal: AbortSignal.timeout(30000),
    redirect: "error",
  });
  if (!response.ok) throw new Error(`Branch API: HTTP ${response.status}`);
  return response.json();
}

let branch = await request(path, "POST", {
  displayName: `agent-test-${randomUUID().slice(0, 8)}`,
});
if (!branch.branchId) throw new Error("Branch API returned no branch ID.");
const branchId = branch.branchId;
console.log("Branch requested:", branchId);

const deadline = Date.now() + 5 * 60 * 1000;
while (branch.state !== "ACTIVE") {
  if (branch.state === "DELETED" || Date.now() >= deadline) {
    throw new Error(`Check branch ${branchId} in the console before retrying.`);
  }
  await wait(5000);
  branch = await request(`${path}/${encodeURIComponent(branchId)}`);
}
console.log("Branch ready:", branchId);
// Connect using this branch's credentials from the TiDB Cloud console.
// Delete this test branch in the console when your experiment is finished.

Persistent Agent State

Persist agent memory, intermediate outputs, and workflow progress in TiDB. Keep code, files, and saved Git state available across sandboxes in TiDB Cloud Filesystem.


// npm install @tidbcloud/serverless@0.3.0
// Set TIDB_URL to a TiDB Cloud connection URL with a database selected.
// Save as persistent-agent-state.mjs and run with Node.js.
import { connect } from "@tidbcloud/serverless";
import { randomUUID } from "node:crypto";

if (!process.env.TIDB_URL) throw new Error("Set TIDB_URL first.");
const db = connect({ url: process.env.TIDB_URL });
await db.execute(`CREATE TABLE IF NOT EXISTS agent_memory_demo (
  agent_id VARCHAR(64) PRIMARY KEY,
  state JSON NOT NULL,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
)`);

async function saveAgentState(agentId, state) {
  await db.execute(
    `INSERT INTO agent_memory_demo (agent_id, state, updated_at)
     VALUES (?, ?, NOW())
     ON DUPLICATE KEY UPDATE state = VALUES(state), updated_at = NOW()`,
    [agentId, JSON.stringify(state)]
  );
}

async function restoreAgentState(agentId) {
  const [row] = await db.execute(
    "SELECT state FROM agent_memory_demo WHERE agent_id = ?",
    [agentId]
  );
  return row ? row.state : null; // JSON columns are already decoded.
}

const agentId = randomUUID(); // Keep this ID to resume the same agent later.
const previousState = (await restoreAgentState(agentId)) ?? {};
await saveAgentState(agentId, {
  ...previousState,
  step: "summarize",
  outputs: ["draft-1.md"],
  tokensUsed: 4210,
});
console.log("Agent ID:", agentId);
console.log("Restored state:", await restoreAgentState(agentId));

Concurrent Transactions for Agent Workflows

Multiple agents can work in parallel. TiDB’s ACID transactions maintain consistency across concurrent database updates.


// npm install @tidbcloud/serverless@0.3.0
// Set TIDB_URL to a TiDB Cloud connection URL with a database selected.
// Save as concurrent-agent-transactions.mjs and run with Node.js.
import { connect } from "@tidbcloud/serverless";
import { randomUUID } from "node:crypto";

if (!process.env.TIDB_URL) throw new Error("Set TIDB_URL first.");
const db = connect({ url: process.env.TIDB_URL });
await db.execute(`CREATE TABLE IF NOT EXISTS agent_tasks_demo (
  id VARCHAR(64) PRIMARY KEY,
  status VARCHAR(20) NOT NULL,
  agent_id VARCHAR(64)
)`);

async function assignTask(taskId, agentId) {
  const tx = await db.begin(); // Each worker gets its own transaction.
  try {
    const [task] = await tx.execute(
      "SELECT status FROM agent_tasks_demo WHERE id = ? FOR UPDATE",
      [taskId]
    );
    if (!task || task.status !== "pending") {
      await tx.rollback();
      return { agentId, claimed: false };
    }
    await tx.execute(
      "UPDATE agent_tasks_demo SET status = ?, agent_id = ? WHERE id = ?",
      ["running", agentId, taskId]
    );
    await tx.commit();
    return { agentId, claimed: true };
  } catch (error) {
    await tx.rollback().catch(() => {});
    throw error;
  }
}

const taskId = randomUUID(); // Use a fresh task on every run.
await db.execute(
  "INSERT INTO agent_tasks_demo (id, status) VALUES (?, ?)",
  [taskId, "pending"]
);
console.log(await Promise.all([
  assignTask(taskId, "agent-A"),
  assignTask(taskId, "agent-B"),
])); // Exactly one agent claims the task; the other returns claimed: false.

Community Contributions

Discover amazing projects built by our community. From developer tools to production applications, see what’s possible with TiDB’s AI-powered capabilities.

FamCare

By Pratik Sharma

AI-powered RAG for healthcare management. Uses TiDB to organize documents, create smart schedules, and power family health chat.

React, TypeScript, Python
healthcare
RAG

AutoIR: Agentic Incident Response

By Younes Laaroussi

Serverless incident response system using TiDB vector search to ingest logs, triage incidents, and generate explainable reports.

Node.js, TypeScript
devops
AWS
vector-search

AI Member of Parliament

By Jianzhi Wang

Event-driven agentic system that automates workflows by finding similar past cases with TiDB vector search and generating appeal letters.

Python
government
ai-agents
vector-search

Heydesk

By Manasseh Zwane

Agentic customer support platform using a custom .NET SDK for TiDB Vector Search to power intelligent ticket routing and real-time chat.

C#, .NET 9, React, TypeScript
customer-support
real-time chat
vector-search

ElitOrcAI

By N DIVIJ

AI clinical decision support that analyzes medical images and uses TiDB for vector similarity search on cases to provide diagnostic guidance.

TypeScript, Next.js
healthcare
medical-imaging
ai-diagnosis

B40 Life Simulator

By Redzwan Latif, Muhammad Shafeeq, Adam Danial

AI life sim game teaching finance via TiDB Cloud for decision storage and behavioral insights.

TypeScript
Game
Social-impact
Analytics

TradrFin

By Chun Rong Lim, Yee Xiong, Andrew Chong, Xin Yu Liew

AI multi-agent trading platform using TiDB for sentiment analysis and market verification.

TypeScript, Python
Fintech
AI-agents

FinanceAssist

By Liew Jin Sze, Pang Lang, Pang Teng, Yi Cheng

AI finance assistant using RAG and TiDB for receipt/transaction insights and records.

TypeScript, Python
Fintech
RAG
AI-agents

SmartFill – AI-Driven Form Fill & Session Automation with TiDB RAG

By Jackson Kasi

Multi-step AI agent using TiDB vector DB for RAG-based web form automation and validation.

TypeScript
RAG
AI Agents
Vector Search

OriginAI – Chrome Extension

By Chris Dabatos

Chrome extension detecting AI text with TiDB backend for logging and feedback analytics.

TypeScript, JavaScript
Browser-extension
AI-detection

Parallel Lives

By Chris Dabatos

AI decision engine simulating outcomes with TiDB for stateful agentic reasoning.

TypeScript
AI Agents
Decision-making
Streaming

Journal It

By Chris Dabatos

AI journaling system using TiDB for semantic search and pattern detection in entries.

TypeScript
AI Agents
Semantic-search

atlasMemory

By Chris Dabatos

Git-style AI memory layer on TiDB with vector/full-text search and branching.

Python, SQL
AI Agents
Memory-layer
Vector-search

LogiFlow AI Intelligent Logistics Management Platform

By Michael Inso

LogiFlow AI platform using TiDB for vector search in logistics automation.

Python, JavaScript, Node.js
AI Agents
Vector-search

Join Our Growing Community

Connect with developers building the future with TiDB.

Github stars
39.4K

GitHub stars

Community Members
25K

Community Members

Contributor
900+

Contributors

Projects
500+

Projects

Hands-On Labs & Tutorials

Get hands-on with TiDB through our curated sandbox projects. Deploy complete applications in minutes and explore AI-powered database capabilities.

60 Min
Beginner

Vector Search with Jupyter

Learn to build AI apps with vector embeddings, RAG, hybrid search, and GraphRAG using TiDB Cloud Starter in 60 minutes.

Python
Jupyter
Vector Search
RAG
90 Min
Intermediate

RAG + Text2SQL with OpenAI

Build intelligent apps that retrieve information and translate natural language to SQL using OpenAI models and TiDB Cloud Starter.

Python
OpenAI
Streamlit
Text2SQL
60 Min
Advanced

GraphRAG AI Agent with OpenAI

Create advanced AI agents with graph-enhanced retrieval and tool calling capabilities using OpenAI and TiDB Cloud Starter integration.

Python
OpenAI
DSPy
GraphRAG
90 Min
Intermediate

RAG + Text2SQL with Bedrock

Develop AI applications with Amazon Bedrock models for retrieval-augmented generation and natural language query translation capabilities.

Python
AWS Bedrock
Streamlit
Text2SQL
90 Min
Intermediate

Unified AI Storage (Amazon Bedrock)

Experience the simplicity of using TiDB as single storage solution versus managing multiple databases for GenAI applications.

Python
AWS Bedrock
PyTiDB
90 Min
Intermediate

Unified AI Storage (OpenAI)

Compare multi-database complexity with TiDB’s unified approach for GenAI applications using OpenAI models and simplified development workflows.

Python
OpenAI
OpenAI
ECOSYSTEM

Integrations

Production-ready integrations for every stage of your AI pipeline.

Quick start: copy paste your Connection String into listed integrations.

Explore All Integrations

Cloud Platform Support

awsazureGoogle_cloud

Resources

Build on the Right Foundation

For Developers

  • TiDB Cloud Starter (Serverless)
  • 25 GiB storage included
  • Deploy your first agent in 5 minutes

Start for Free

OR

For Platform Builders

Talk to Our AI Infrastructure Experts

  • Architecture review
  • Solve your specific scaling challenges
  • Migration planning & dedicated support

Book Architecture Review