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.
pip install weaviate-clientVerified import paths — ran on the pinned version, not inferred.
v4 uses context manager (with ... as client) to manage connection lifecycle. collections.use() is the preferred method (collections.get() deprecated in 4.18).
Migrate to v4 API: replace weaviate.Client() with weaviate.connect_to_local() / connect_to_weaviate_cloud() / connect_to_custom(). Full migration guide: docs.weaviate.io/weaviate/client-libraries/python/v3_v4_migration. Or pin: pip install 'weaviate-client>=3.26.7,<4.0.0' — but v3 receives no new features.
Upgrade Weaviate server first. Check compatibility matrix in the release notes. Client minor versions track server minor versions (e.g., client 4.9.x pairs with server 1.27.x).
Add port mapping 50051:50051 to docker-compose.yml. For connect_to_custom(), specify both http_host/http_port and grpc_host/grpc_port explicitly.
Replace Configure.NamedVectors.* with Configure.Vectors.* and Configure.MultiVectors.* for multi-vector configurations. Replace Configure.Vectorizer.none() with Configure.Vectors.self_provided().
Switch to API key authentication: Auth.api_key('your-api-key') passed to auth_credentials in connect_to_weaviate_cloud().Always use context manager pattern or call client.close() in a finally block. Do not instantiate WeaviateClient at module level without explicit lifecycle management.
Replace client.collections.get('Name') with client.collections.use('Name') in all new code.