Skip to main content
Go to documentation:
⌘U
Weaviate Database

Develop AI applications using Weaviate's APIs and tools

Deploy

Deploy, configure, and maintain Weaviate Database

Weaviate Agents

Build and deploy intelligent agents with Weaviate

Weaviate Cloud

Manage and scale Weaviate in the cloud

Additional resources

Integrations
Contributor guide
Events & Workshops
Weaviate Academy

Need help?

Weaviate LogoAsk AI Assistant⌘K
Community Forum

Quickstart: With Cloud resources

Weaviate is an open-source vector database built to power AI applications. This quickstart guide will show you how to:

  1. Set up a collection - Create a collection and import data into it.
  2. Search - Perform a similarity (vector) search on your data.
  3. RAG - Perform Retrieval Augmented Generation (RAG) with a generative model.
  4. Query Agent - Get answers from you data by using a natural language prompt/question. Cloud only

If you encounter any issues along the way or have additional questions, use the feature.

Prerequisites

A Weaviate Cloud Sandbox instance - you will need an admin API key and a REST endpoint URL to connect to your instance. See the instructions below for more info. If you don't want to use Weaviate Cloud, check out the Local Quickstart with Docker.

How to set up a Weaviate Cloud Sandbox instance

Go to the Weaviate Cloud console and create a free Sandbox instance as shown in the interactive example below.


note
  • Cluster provisioning typically takes 1-3 minutes.
  • When the cluster is ready, Weaviate Cloud displays a checkmark (✔️) next to the cluster name.
  • Note that Weaviate Cloud adds a random suffix to sandbox cluster names to ensure uniqueness.
How to retrieve Weaviate Cloud credentials (WEAVIATE_API_KEY and WEAVIATE_URL)

After you create a Weaviate Cloud instance, you will need the:

  • REST Endpoint URL and the
  • Administrator API Key.

You can retrieve them both from the WCD console as shown in the interactive example below.


REST vs gRPC endpoints

Weaviate supports both REST and gRPC protocols. For Weaviate Cloud deployments, you only need to provide the REST endpoint URL - the client will automatically configure gRPC.

Once you have the REST Endpoint URL and the admin API key, you can connect to the Sandbox instance, and work with Weaviate.


Install a client library

Follow the instructions below to install one of the official client libraries, available in Python, JavaScript/TypeScript, Go, and Java.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
pip install -U weaviate-client[agents]

Step 1: Create a collection & import data

There are two paths you can choose from when importing data:


The following example creates a collection called Movie. The data will be vectorized with the Weaviate EmbeddingsWeaviate Embeddings is a managed embedding inference service for Weaviate Cloud users (embedding model provider). It generates vector embeddings for your data and queries directly from a Weaviate Cloud database instance. model provider. You are also free to use any other available embedding model provider.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
import weaviate
from weaviate.classes.config import Configure
import os

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Step 1.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url,
auth_credentials=weaviate_api_key,
) as client:

# Step 1.2: Create a collection
movies = client.collections.create(
name="Movie",
vector_config=Configure.Vectors.text2vec_weaviate(), # Configure the Weaviate Embeddings vectorizer
)

# Step 1.3: Import three objects
data_objects = [
{"title": "The Matrix", "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.", "genre": "Science Fiction"},
{"title": "Spirited Away", "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.", "genre": "Animation"},
{"title": "The Lord of the Rings: The Fellowship of the Ring", "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.", "genre": "Fantasy"},
]

movies = client.collections.use("Movie")
with movies.batch.fixed_size(batch_size=200) as batch:
for obj in data_objects:
batch.add_object(properties=obj)

print(f"Imported & vectorized {len(movies)} objects into the Movie collection")

Semantic search finds results based on meaning. This is called nearText in Weaviate. The following example searches for 2 objects (limit) whose meaning is most similar to that of sci-fi.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
import weaviate
import os, json

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Step 2.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url,
auth_credentials=weaviate_api_key,
) as client:

# Step 2.2: Use this collection
movies = client.collections.use("Movie")

# Step 2.3: Perform a semantic search with NearText
response = movies.query.near_text(
query="sci-fi",
limit=2
)

for obj in response.objects:
print(json.dumps(obj.properties, indent=2)) # Inspect the results
Example response
{
"genre": "Science Fiction",
"title": "The Matrix",
"description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers."
}
{
"genre": "Fantasy",
"title": "The Lord of the Rings: The Fellowship of the Ring",
"description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth."
}

Step 3: Retrieval augmented generation (RAG)

Requirement: Claude API key

For Retrieval Augmented Generation (RAG) in this step, you will need a Claude API key. You can also use another generative model provider instead.

Retrieval augmented generation (RAG), also called generative search, works by prompting a large language model (LLM) with a combination of a user query and data retrieved from a database.

The following example combines the semantic search for the query sci-fi with a prompt to generate a tweet using the Anthropic generative model (generative-anthropic).

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
import os
import weaviate
from weaviate.classes.generate import GenerativeConfig

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]
anthropic_api_key = os.environ["ANTHROPIC_API_KEY"]

# Step 2.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url,
auth_credentials=weaviate_api_key,
headers={"X-Anthropic-Api-Key": anthropic_api_key},
) as client:

# Step 2.2: Use this collection
movies = client.collections.use("Movie")

# Step 2.3: Perform RAG with on NearText results
response = movies.generate.near_text(
query="sci-fi",
limit=1,
grouped_task="Write a tweet with emojis about this movie.",
generative_provider=GenerativeConfig.anthropic(
model="claude-3-5-haiku-latest"
), # Configure the Anthropic generative integration for RAG
)

print(response.generative.text) # Inspect the results
Example response
🕶️ Unplug from the system & join Neo's journey 💊🐰

"The Matrix" will blow your mind 🤯 as reality unravels 🌀

Kung-fu, slow-mo & mind-bending sci-fi 🥋🕴️

Are you ready to see how deep the rabbit hole goes? 🔴🔵 #TheMatrix #WakeUp

Step 4: Query Agent

Weaviate Cloud only

The Weaviate Query Agent is a pre-built agentic service designed to answer natural language queries based on the data stored in Weaviate Cloud. The user simply provides a prompt/question in natural language, and the Query Agent takes care of all intervening steps to provide an answer.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
import os
import weaviate
from weaviate.agents.query import QueryAgent

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Step 2.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url,
auth_credentials=weaviate_api_key,
) as client:

# Step 2.2: Instantiate a new agent object
qa = QueryAgent(client=client, collections=["Movie"])

# Step 2.3: Perform a query using Search Mode
response = qa.search("Find a cool sci-fi movie.", limit=1)

# Print the response
for obj in response.search_results.objects:
print(f"Movie: {obj.properties['title']} - {obj.properties['description']}")

Here is the printed response:

Movie: The Matrix - A computer hacker learns about the true nature of reality and his role in the war against its controllers.

Next steps

We recommend you check out the following resources to continue learning about Weaviate.


Questions and feedback

If you have any questions or feedback, let us know in the user forum.