TiDB Vector Search for Generative AI

One database for all your AI ambitions: Vector Search, Knowledge Graphs, and Operational Data - with enterprise-grade reliability and serverless simplicity.

Trusted by the world's most innovative teams

TransistorReformSavvyCalTupleStatamicHollaGroupDifyTransistorReformSavvyCalTupleStatamicHollaGroupDify

Your AI Stack, Simplified.

TiDB is your complete database solution for AI applications. One rules all:

1# Define schema
2class Doc(Base):
3    __tablename__ = "doc"
4    id = Column(Integer, primary_key=True)
5    content = Column(Text)
6    embedding = Column(VectorType(dim=3))
7
8# Create table and index
9Base.metadata.create_all(engine)
10VectorAdaptor(engine).create_vector_index(
11    Doc.embedding, tidb_vector.DistanceMetric.L2
12)
13
14# Insert
15with Session(engine) as session:
16    session.add(Doc(content="dog",  embedding=[1, 2, 1]))
17    session.add(Doc(content="fish", embedding=[1, 2, 4]))
18    session.commit()
19
20# Search nearest 1 embedding using L2 distance
21with Session(engine) as session:
22    results = session.execute(
23        select(Doc.content)
24        .order_by(Doc.embedding.l2_distance([1, 2, 3]))
25        .limit(1)
26    ).all()
27    print(results)

TiDB Vector Search in Action

TiDB.AI: an intelligent documentation assistant built with GraphRAG technology, powered by TiDB Vector Search.

video
Key Features
  • Contextual answers from TiDB documentation
  • Knowledge graph enhanced reasoning
  • Open-source implementation
No Provision, No Capacity Planning

Pay Only for What You Actually Use

Vector dimension:
768
5127681536
Rows in table:
1M
01M2M3M4M
Write Rows:
1M
01M2M3M4M
Read Queries:
100K
0200K400K600K800K1M
Estimated storage cost:
$1.32 per month
Estimated request cost:
$5.15
The above estimated price is for your reference only. The actual price will be calculated based on your actual usage of Serveless services, including but not limited to the network transfer fee, region, workload, usage of non-vector data, etc. For more details, please refer to Pricing Details or contact us.

Run it on Cloud

  • Free for 25GiB storage and 250 million RU per month
  • Scale instantly in response to your workload
  • Zero cost when idle
OR

Run it Locally

Run TiDB locally with full features
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
~/.tiup/bin/tiup playground nightly --tag my_vector_db
Read Docs

* Supported platforms: Linux (x64 / ARM64), MacOS (x64 / ARM64)

Integrations

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

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

Explore All Integrations

bg
Trusted by Industry Leaders
Dify logo

Leading LLMOps platform enabling organizations to build and deploy AI applications, serving hundreds of thousands of customers with millions of daily AI interactions.

Challenge

Managing separate databases for vector and relational data consumed valuable engineering resources while performance fluctuated unpredictably as tenant workloads varied.

Solution

Implemented TiDB Cloud Serverless as a unified database solution that handles both vector and relational data with automated scaling capabilities.

Services Used

Leveraged TiDB Cloud Serverless with vector search capabilities to power their entire data infrastructure, serving over 300,000 database containers.

Outcomes

Achieved consistent performance across 100M+ records while reducing infrastructure costs and simplifying database management through automated operations.

Luyu Zhang
Luyu Zhang
Founder & CEO of Dify.AI

With TiDB, our users can concentrate on building their GenAI apps rather than worrying about setup. Our engineers have automated all database management tasks using TiDB's API, significantly reducing our time and effort. The scale-to-zero capability of TiDB lets us provide dedicated databases to our customers without the burden of idle resource costs.

Build with Confidence

Enterprise-grade Security

Compliant

We are in compliance with the latest industry standards: SOC2 Type II and SOC3 certified, EU CoC, PCI DSS and HIPAA compliant.

Secure

TiDB Serverless supports Role-based Access Control, Encryption at rest, Private Link, and more.

High Available

TiDB Serverless offers 99.9% uptime SLA and Zonal HA by default. Supports cross-AZ HA and automatic backups.

FAQ

TiDB Vector Search

Build Intelligent Applications with TiDB Vector Search.

Start for Free