Get started with generative AI Stay organized with collections Save and categorize content based on your preferences.
This page helps you get started with implementing generative AI features in yourapp. It describes the features and integrations for Firestore that involvegenerative AI.
Quickstart for vector search withCloud Firestore
Creating innovative AI-powered solutions for use cases such as productrecommendations and chatbots often requires vector similarity search, or vectorsearch for short. You can perform vector search on Firestore data without thehassle of copying data to another vector search solution, maintainingoperational simplicity and efficiency.
The core workflow for vector search inCloud Firestore consists of 4 steps.
Understand vector search fully in our blog post
Generatevector embeddings
The first step in utilizing vector search is to generate vector embeddings.Embeddings are representations of different kinds of data like text, images,and video that capture semantic or syntactic similarities between the entitiesthey represent. Embeddings can be calculated using a service, such as theVertex AI text-embeddings API.
Storeembeddings in Firestore
Once the embeddings are generated you can store them in Firestore using one ofthe supported SDKs. Here is what that operation looks like in the NodeJS SDK:
constdb=newFirestore();letcollectionRef=db.collection("beans");awaitcollectionRef.add({name:"Kahawa coffee beans",type:"arabica",description:"Information about the Kahawa coffee beans.",embedding_field:FieldValue.vector([0.1,0.3,...,0.2]),// a vector with 768 dimensions});
Createa vector index
The next step is to create a Firestore KNN vector index where the vectorembeddings are stored. During the preview release, you will need to create theindex using thegcloud
command line tool.
Performthe vector search
Once you have added all the vector embeddings and created the vector index, youare ready to run the search. You will then utilize thefind_nearest
call on acollection reference to pass the query vector embedding with which to comparethe stored embeddings and to specify the distance function you want to utilize.
Once again, explore the workflow and more use cases in ourblog post.
Solution: vector search
Summary: Store and query vector embeddings.
Use case: This feature is used by the other tools and features.
See the guide for vector search
Solution: extension for vector search with Firebase
Summary: Use the Firebase extension to automatically embed and query yourFirestore documents with the vector search feature.
Use case: Perform automatic vector search in your Firebase projects.
Review the extension description
Solution: LangChain integrations
Summary: Use Firestore as a vector store, document loader, or chat messagehistory source for LangChain.
Use case: Build generative AI applications or retrieval-augmented generation(RAG) workflows.
Solution: Genkit
Summary: Genkit is an open source framework that helps you build,deploy, and monitor production-ready AI-powered apps.
Use case: Use Genkit andCloud Firestore to create apps that generatecustom content, use semantic search, handle unstructured inputs, answerquestions with your business data, and much more!
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-10 UTC.