To use Weaviate with LangChain, install langchain-weaviate and the v4 weaviate-client, connect to a Weaviate 1.23.7+ (better 1.27+) instance, create a collection with Configure.Vectors.self_provided() when you embed in LangChain, wrap the client in WeaviateVectorStore, load your documents, then call similarity_search or hand as_retriever() to a tool for create_agent. The short path that fails on current Weaviate is from_documents with the package default schema: it creates a collection with no vector index, so inserts that send vectors error out.
We checked this against the LangChain Weaviate integration docs, the Weaviate Python client docs and the langchain-weaviate package on PyPI on November 4, 2026, and ran the flow on Embedded Weaviate 1.40.2 with FakeEmbeddings so no API key was needed. For what Weaviate is and when to pick it over other stores, see what Weaviate is and Weaviate vs pgvector.
What you need
| Piece | What we used | Notes |
|---|---|---|
| Python | 3.13 | Client needs 3.10+ |
weaviate-client | 4.24.1 | Official v4 client |
langchain-weaviate | 0.0.8 | Ships WeaviateVectorStore |
langchain | 1.4.9 | create_agent lives here |
| Weaviate server | Embedded 1.40.2 | Docs minimum for the integration is 1.23.7; v4 client docs ask for 1.27+ |
| Embeddings | FakeEmbeddings(size=32) in the test | Swap for OpenAI, Ollama or any LangChain embeddings class |
You also need ports for REST and gRPC. Local Docker usually maps 8080 and 50051. Embedded Weaviate on this box listened on 8079 and 50050. Close the client when you finish (client.close()), or use a with block.
Step 1: Install the packages
pip install -U langchain-weaviate weaviate-client langchain langchain-text-splitters
Use langchain-weaviate, not an older community import. The LangChain docs show from langchain_weaviate import WeaviateVectorStore (or from langchain_weaviate.vectorstores import WeaviateVectorStore). Add an embeddings package when you leave FakeEmbeddings behind, for example langchain-openai or langchain-ollama (see how to use LangChain with Ollama).
Step 2: Connect to Weaviate
import weaviate
client = weaviate.connect_to_local() # Docker on 8080 / 50051
# client = weaviate.connect_to_embedded() # Linux/macOS notebook helper
# client = weaviate.connect_to_weaviate_cloud(
# cluster_url="https://YOUR_CLUSTER",
# auth_credentials=weaviate.auth.AuthApiKey("YOUR_KEY"),
# )
print(client.is_ready(), client.get_meta()["version"])
The integration needs a v4 client object (weaviate.WeaviateClient). Cloud clusters and many shared instances need an API key. Embedded mode is marked experimental in the Weaviate docs and is fine for local tests; for anything lasting, use Docker or Weaviate Cloud. Our what is Weaviate guide shows a one line Docker run for 1.40.3.
Step 3: Create a collection that accepts your vectors
This is the step most copy paste tutorials skip, and it is where our test broke first.
On Weaviate 1.40.2, WeaviateVectorStore.from_documents(...) with the package default schema creates a collection that has no vector index. When LangChain then sends vectors from your embeddings model, every object in the batch fails with collection ... is configured without a vector index, but received a vector. In our run those failures were logged and the call did not raise a clean Python exception, so a quiet empty index is easy to miss.
Create the collection yourself when LangChain owns the embeddings:
from weaviate.classes.config import Configure, Property, DataType
if client.collections.exists("AgentDocs"):
client.collections.delete("AgentDocs")
client.collections.create(
name="AgentDocs",
properties=[
Property(name="text", data_type=DataType.TEXT),
Property(name="source", data_type=DataType.TEXT),
Property(name="ticket", data_type=DataType.TEXT),
],
vector_config=Configure.Vectors.self_provided(),
)
self_provided means your app (LangChain embeddings) supplies the vector. If you would rather have Weaviate embed text with a module such as text2vec-ollama or a cloud vectorizer, configure that on the collection instead and do not send vectors from LangChain. Mixing the two without matching config is what triggers the error above.
Step 4: Wrap the client and load documents
from langchain_core.documents import Document
from langchain_core.embeddings import FakeEmbeddings # replace in real apps
from langchain_weaviate import WeaviateVectorStore
embeddings = FakeEmbeddings(size=32)
store = WeaviateVectorStore(
client=client,
index_name="AgentDocs",
text_key="text",
embedding=embeddings,
attributes=["source", "ticket"],
)
docs = [
Document(
page_content="Order A17 shipped on November 3 from the Dallas warehouse.",
metadata={"source": "orders.md", "ticket": "A17"},
),
Document(
page_content="Refund policy: returns accepted within 30 days with receipt.",
metadata={"source": "policy.md", "ticket": "P1"},
),
Document(
page_content="The agent memory layer stores prior tool results for later turns.",
metadata={"source": "memory.md", "ticket": "M1"},
),
]
store.add_documents(docs)
attributes lists metadata fields to return on search. Keep text_key aligned with the property name you created. For larger corpora, split with langchain-text-splitters first, then call add_documents or add_texts.
Step 5: Search, filter and tune hybrid alpha
similarity_search in langchain-weaviate uses Weaviate hybrid search (vector plus keyword). Pass alpha to weight the vector leg: 1 is pure vector, 0 is pure keyword.
from weaviate.classes.query import Filter
hits = store.similarity_search("Where did order A17 ship from?", k=2)
keyword_hits = store.similarity_search("Order A17 Dallas", k=2, alpha=0.0)
filtered = store.similarity_search(
"shipped",
k=5,
filters=Filter.by_property("source").equal("orders.md"),
)
In our FakeEmbeddings run, pure keyword search (alpha=0) returned the order line for "Order A17", and the source == orders.md filter returned exactly one document. Fake embeddings are not meaningful for ranking, so treat those vector ranks as a wiring check only. With a real embedding model, keep the same model for index and query.
You can also call similarity_search_with_score or build a retriever with MMR:
retriever = store.as_retriever(search_type="mmr", search_kwargs={"k": 4})
Step 6: Multi tenancy for per user agent memory
Pass a tenant when you add and when you search. On first write for a new tenant name, langchain-weaviate creates the tenant if multi tenancy is enabled.
client.collections.create(
name="AgentDocsMT",
properties=[
Property(name="text", data_type=DataType.TEXT),
Property(name="source", data_type=DataType.TEXT),
],
vector_config=Configure.Vectors.self_provided(),
multi_tenancy_config=Configure.multi_tenancy(
enabled=True, auto_tenant_creation=True
),
)
mt = WeaviateVectorStore(
client=client,
index_name="AgentDocsMT",
text_key="text",
embedding=embeddings,
attributes=["source"],
use_multi_tenancy=True,
)
mt.add_documents([docs[0]], tenant="user_42")
print(mt.similarity_search("Dallas", k=1, tenant="user_42")[0].page_content)
# mt.similarity_search("Dallas", k=1, tenant="other_user")
# -> raises: tenant not found: "other_user"
Pick the tenant from your authenticated session in application code, never from free text the model produced. That pattern matches how we talk about tenants in what Weaviate is and in the AI agent memory comparison.
Step 7: Wire Weaviate into a LangChain agent
Turn the store into a tool and pass it to create_agent. Under the hood you get a compiled LangGraph graph (CompiledStateGraph in our test).
from langchain_core.tools import tool
from langchain.agents import create_agent
@tool
def docs_search(query: str) -> str:
"""Search internal docs for order and policy facts."""
found = store.similarity_search(query, k=2)
return "\n".join(doc.page_content for doc in found)
# Replace ScriptedToolModel with init_chat_model(...) or ChatOllama(...)
agent = create_agent(model, tools=[docs_search])
result = agent.invoke({"messages": [("user", "Where did order A17 ship from?")]})
print(result["messages"][-1].content)
Our scripted model called docs_search, received the tool message, then answered Order A17 shipped from the Dallas warehouse. Message types on the trace were human, ai, tool, ai. For a fuller graph with rewrite loops and graders, follow how to build a RAG pipeline with LangGraph. For MCP style access to Weaviate outside LangChain, see MCP server vs vector database and the Weaviate MCP notes in what Weaviate is.
Always close the client when the process is done:
client.close()
Common mistakes
- Default
from_documentson Weaviate 1.40 with app side embeddings. Create the collection withConfigure.Vectors.self_provided()first, or configure a Weaviate vectorizer and stop sending vectors from LangChain. - v3 client leftovers. The integration expects a v4
WeaviateClient. The v3 client is deprecated. - Missing gRPC port. Queries go over gRPC; map
50051(or your embedded grpc port) or searches fail even when REST looks healthy. - Wrong tenant string. A search for a tenant that was never created raises
tenant not found. Create tenants on write, or enable auto tenant creation with care. - Embedding mismatch. Index and query must use the same embedding model and dimension.
- Leaving the client open. Call
client.close()in long running agents so connections do not leak across requests.
When to use Weaviate with LangChain
Pick this combo when you want LangChain loaders, splitters and create_agent, plus Weaviate features such as hybrid search, tenants and (if you enable it) a database side MCP server. Prefer Qdrant when you want payload filters and hybrid search with embeddings always computed in your app (Qdrant how to). Prefer pgvector when Postgres is already your system of record (Weaviate vs pgvector). Prefer a managed memory product when you do not want to design the schema yourself (Mem0 vs Letta vs Zep).
FAQ
Which package do I install for Weaviate in LangChain?
Install langchain-weaviate together with weaviate-client v4. Import WeaviateVectorStore from langchain_weaviate. Do not start new projects on the old community Weaviate classes.
Does similarity_search use hybrid search?
Yes. The LangChain Weaviate docs state that similarity_search uses Weaviate hybrid search. Pass alpha to change the vector versus keyword balance (0 is keyword only).
Why do inserts fail with "configured without a vector index"?
On Weaviate 1.40.2, the default schema that langchain-weaviate 0.0.8 creates through from_documents has no vector index. Create the collection with Configure.Vectors.self_provided() when LangChain supplies embeddings, then call add_documents on an existing index.
Can I use Weaviate as memory for a LangChain agent?
Yes. Store facts or document chunks per tenant, wrap similarity_search in a @tool, and pass that tool to create_agent. Scope every read and write with the signed in user id as the tenant name.
Do I need Docker, or is Embedded Weaviate enough?
Embedded Weaviate is enough for local tests on Linux and macOS. For shared or production use, run Docker or Weaviate Cloud so persistence, auth and ports are explicit.
How is this different from using Weaviate's own MCP server?
LangChain talks to Weaviate as a vector store inside your Python process. The Weaviate MCP server exposes query and upsert tools over HTTP for any MCP client. You can use both, but they solve different wiring problems. See MCP server vs vector database.



