📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

TiDB for AI



TiDB provides data and workspace capabilities for building AI applications and running AI agent workflows.

  • For application development, you can use SQL or Python SDK for TiDB AI (pytidb) with structured data, vector search, full-text search, hybrid search, and AI-powered retrieval.
  • For AI agents and automation, you can use TiDB Cloud CLI (ti) to manage TiDB Cloud Starter instances and SQL workflows, and use TiDB Cloud Filesystems as persistent, shared storage across local machines, CI jobs, and ephemeral agent sandboxes. Filesystems also support mounted workspaces, Git workflows, journals, and delegated secrets.

Get started

Choose a path based on what you want to build:

GoalStart here
Build an AI application with vector searchGet Started with Vector Search via Python or Get Started with Vector Search via SQL
Build agent and automation workflows with TiDB CloudGet Started with TiDB Cloud CLI

Build AI applications with TiDB

Use the pytidb SDK or SQL to connect to TiDB, search and retrieve data, and build AI-powered applications.

Connect to TiDB

DocumentDescription
Connect to TiDB via PythonConnect to TiDB Cloud or TiDB Self-Managed using pytidb.

Search & retrieval

DocumentDescription
Vector Search OverviewComprehensive overview of vector search, including concepts, how it works, and use cases.
Vector Search GuidePerform semantic similarity searches using pytidb.
Vector Search ExampleSemantic similarity search example with pytidb.
DocumentDescription
Full-Text Search via PythonKeyword-based text search with BM25 ranking using pytidb.
Full-Text Search via SQLKeyword-based text search with BM25 ranking using SQL.
Full-Text Search ExampleFull-text search example with pytidb.
DocumentDescription
Hybrid Search GuideCombine vector and full-text search for better results.
Hybrid Search ExampleHybrid search example with pytidb.

Auto embeddings

DocumentDescription
Auto Embedding GuideAutomatically generate embeddings on data insertion.
Auto Embedding ExampleAuto embedding example with pytidb.
DocumentDescription
Image Search GuideSearch images using multimodal embeddings.
Image Search ExampleMultimodal image search example with Jina AI embeddings.

Reranking

DocumentDescription
RerankingRerank search results for improved relevance.

Work with data

DocumentDescription
Working with TablesCreate, query, and manage tables with vector fields.
FilteringFilter search results with metadata conditions.
Join QueriesPerform join queries across tables.
Raw SQL QueriesExecute raw SQL queries directly.
TransactionsUse transactions for data consistency.

Application examples

DocumentDescription
RAG ExampleBuild a Retrieval-Augmented Generation application.
Conversational Memory ExamplePersistent memory for AI agents and chatbots.
Text-to-SQL ExampleConvert natural language to SQL queries.

Build agent and automation workflows with TiDB Cloud CLI

The TiDB Cloud CLI (ti) lets users, scripts, CI jobs, and AI agents manage TiDB Cloud from a terminal. Use it to automate TiDB Cloud Starter and SQL operations or to keep files and workspaces available independently of the machines and sandboxes that use them.

What you want to doStart here
Understand what ti manages and when to use itTiDB Cloud CLI Overview
Install and configure ti, then complete a first workflowGet Started with TiDB Cloud CLI
Automate TiDB Cloud Starter instance, branch, and SQL operationsManage TiDB Cloud Starter Instances
Persist and share files across machines, CI jobs, and sandboxesManage Filesystem Resources and Work with Filesystem Data
Use mounted workspaces, Git workspaces, journals, or delegated secretsMount a Filesystem, Manage Git Workspaces, Use Filesystem Journals, and Manage Filesystem Vault Secrets
Follow an end-to-end automation or agent exampleRun a Daily TiDB Cloud CLI Workflow or Use TiDB Cloud Filesystem in an Agent Sandbox
Look up commands, global options, output behavior, and errorsTiDB Cloud CLI Command Reference

Integrations

Connect TiDB to embedding providers, AI frameworks, application libraries, cloud services, and AI development tools.

Integration areaStart here
All integrationsAI Integrations for TiDB
Auto Embedding providersAuto Embedding Overview
AI frameworksLlamaIndex
ORM librariesSQLAlchemy, Django ORM, and Peewee
Cloud embedding servicesJina AI Embedding and Amazon Bedrock
MCP clients and AI development toolsTiDB MCP Server

Reference

Technical reference documentation for TiDB's AI and vector search features.

DocumentDescription
Vector Data TypesVector column types and usage.
Vector Functions and OperatorsDistance functions and vector operations.
Vector Search IndexCreate and manage vector indexes for performance.
Vector Search Performance TuningOptimize vector search performance.
Vector Search LimitationsCurrent limitations and constraints.

Was this page helpful?