Weaviate Python Client
Official Python client for the Weaviate vector database. v4 is a complete rewrite from v3 — uses gRPC for data operations (significantly faster), strong typing, collection-centric API, and context manager connection lifecycle. v3 API (weaviate.Client class) removed from the v4 package as of late 2024. Compatible with Weaviate server >= 1.23.7. Supports local, cloud (Weaviate Cloud), and custom deployments.
Warnings
- breaking weaviate.Client() (v3 API) removed from weaviate-client >= 4.0.0 as of late 2024. Raises AttributeError. Enormous volume of tutorials, LangChain/LlamaIndex integration docs, and LLM-generated code uses v3 patterns.
- breaking v4 client requires Weaviate server >= 1.23.7. v4.9+ aligns with Weaviate >= 1.27. Connecting v4 client to older servers raises gRPC errors or returns unexpected API responses.
- breaking gRPC port 50051 must be open to Weaviate server. v4 client uses gRPC for all data operations. Docker deployments that only expose port 8080 (HTTP) fail with WeaviateGRPCUnavailableError on any query/insert.
- breaking Configure.NamedVectors renamed to Configure.Vectors in v4.16.0. Configure.Vectorizer.none() renamed to Configure.Vectors.self_provided(). Code written against 4.15.x and earlier breaks on upgrade.
- breaking OIDC authentication for Weaviate Cloud deprecated in v4.16+, removed in early August 2025. Raises deprecation warning then AuthenticationFailedError.
- gotcha v4 client must be used as a context manager (with weaviate.connect_to_local() as client:) or client.close() must be called explicitly. Failing to close leaks gRPC connections and eventually causes channel exhaustion.
- gotcha collections.get() is deprecated in 4.18.0 and will be removed. New code should use collections.use() which is an exact functional equivalent introduced as the preferred alias.
Install
-
pip install weaviate-client -
pip install 'weaviate-client[agents]' -
pip install 'weaviate-client>=3.26.7,<4.0.0'
Imports
- connect_to_local / connect_to_weaviate_cloud / WeaviateClient
import weaviate client = weaviate.connect_to_local() # local client = weaviate.connect_to_weaviate_cloud(cluster_url=..., auth_credentials=...) # cloud
- collections.use (preferred) vs collections.get (deprecated)
collection = client.collections.use('MyCollection') - Configure.Vectors (new) vs Configure.NamedVectors (removed)
from weaviate.classes.config import Configure Configure.Vectors.text2vec_openai()
Quickstart
import weaviate
from weaviate.classes.init import Auth
# Local Weaviate instance
with weaviate.connect_to_local() as client:
# Create or get collection
if not client.collections.exists('Documents'):
client.collections.create('Documents')
collection = client.collections.use('Documents')
# Insert object
uuid = collection.data.insert({'text': 'Hello world', 'source': 'test'})
# Query
results = collection.query.near_text(query='hello', limit=5)
for obj in results.objects:
print(obj.properties)