Weaviate Cookbooks
WeaviateOfficialPublished by Weaviate
- Skill
- Tool integration
- Data and AI
- BSD-3-Clause
- Medium risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The Weaviate Cookbooks skill serves as a central repository for developers building AI-powered applications using the Weaviate vector database. It provides structured guidance on architectural patterns, ranging from basic RAG implementations to complex agentic workflows. The skill emphasizes best practices for project setup, environment management, and integration, offering specific blueprints for chatbots, data explorers, and multimodal document search systems. It is designed to help developers scaffold full-stack applications efficiently by providing modular references and standardized implementation strategies.
What it does
- Provides architectural blueprints for building RAG and agentic systems.
- Offers standardized project setup and environment configuration guidelines.
- Includes specific implementation guides for chatbots, data explorers, and multimodal search.
- Provides best practices for using the Weaviate Python async client in production.
- Offers guidance on integrating frontend interfaces with Weaviate backends.
- Directs users to official resources for Weaviate Cloud instance management.
When to use it
- When you need to build an AI application powered by Weaviate.
- When you are looking for architectural patterns for RAG or agentic workflows.
- When you need to set up a new Weaviate-based project with industry best practices.
- When you need guidance on implementing advanced features like re-ranking or query decomposition.
- When you are building a frontend interface to interact with a Weaviate backend.
Advantages
- Reduces development time with ready-to-use architectural blueprints.
- Ensures consistent project structure and dependency management.
- Provides clear paths for scaling from basic RAG to advanced agentic systems.
- Offers modular, reference-based learning for specific Weaviate features.
- Promotes the use of modern development tools like uv for dependency management.
Usage examples
- “How do I build a basic RAG system with Weaviate?”
- The agent will provide the steps from the Basic RAG cookbook, including project setup, environment requirements, and the core retrieval logic.
- “I need to build an agent that uses RAG to answer questions. Where should I start?”
- The agent will guide you through the Agentic RAG cookbook, explaining how to implement naive RAG tools or hierarchical RAG with LLM-created filters.
- “How can I improve my RAG system's performance?”
- The agent will reference the Advanced RAG cookbook, suggesting techniques like query re-writing, decomposition, and re-ranking.
- “I want to build a frontend for my Weaviate data explorer.”
- The agent will provide the Frontend Interface reference, detailing how to connect a Next.js frontend to your Weaviate backend.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/weaviate/weaviate-cookbooks/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip weaviate-cookbooks.zip -d .agents/skills
Documentation by Weaviate
Weaviate Cookbooks
Overview
This skill provides an index of implementation guides and foundational requirements for building Weaviate-powered AI applications. Use the references to quickly scaffold full-stack applications with best practices for connection management, environment setup, and application architecture.
Weaviate Cloud Instance
If the user does not have an instance yet, direct them to the cloud console to register and create a free sandbox. Create a Weaviate instance via Weaviate Cloud.
Before Building Any Cookbook
Follow these shared guidelines before generating any cookbook app:
Then proceed to the specific cookbook reference below.
Cookbook Index
Query Agent Chatbot: Build a full-stack chatbot using Weaviate Query Agent with streaming and chat history support.
Data Explorer: Build a full-stack data explorer app including sorting, keyword search and tabular view of weaviate data.
Multimodal RAG: Building Document Search: Build a multimodal Retrieval-Augmented Generation (RAG) system using Weaviate Embeddings (ModernVBERT/colmodernvbert) and Ollama with Qwen3-VL for generation.
Basic RAG: Implement basic retrieval and generation with Weaviate. Useful for most forms of data retrieval from a Weaviate collection.
Advanced RAG: Improve on basic RAG by adding extra features such as re-ranking, query decomposition, query re-writing, LLM filter selection.
Basic Agent: Build a tool-calling AI agent with structured outputs using DSPy. Covers AgentResponse signatures, RouterAgent, tool design, and sequential multi-step loops.
Agentic RAG: Build RAG-powered AI agents with Weaviate. Covers naive RAG tools, hierarchical RAG with LLM-created filters, vector DB memory, Weaviate Query Agent, and Elysia integration.
Interface (Optional)
Use this when the user explicitly asks for a frontend for their Weaviate backend.
Frontend Interface: Build a Next.js frontend to interact with the Weaviate backend.
Client Usage
Async Client: Guide for using the Weaviate Python async client in production applications (FastAPI, async frameworks). Covers connection patterns, lifecycle management, common pitfalls, and multi-cluster setups.
Files
- ATTRIBUTION.mdAdded by AutoGineer874 B
- LICENSELicence file added by AutoGineer1.5 KiB
- SKILL.md3.1 KiB
- references/advanced_rag.md10.4 KiB
- references/agentic_rag.md13.3 KiB
- references/async_client.md14.6 KiB
- references/basic_agent.md10.3 KiB
- references/basic_rag.md6.3 KiB
- references/data_explorer.md11.3 KiB
- references/environment_requirements.md2.6 KiB
- references/frontend_interface.md4.7 KiB
- references/pdf_multimodal_rag.md19.7 KiB
- references/project_setup.md1.4 KiB
- references/query_agent_chatbot.md5.8 KiB
references/async_client.md
Async Client Usage
Guide for using the Weaviate Python async client in production applications (FastAPI, async frameworks).
📚 Official Documentation Reference
For agents: If you encounter any issues not covered here, refer to the official Weaviate documentation:
Primary Reference: Weaviate Async API Documentation
Python Client Reference: Weaviate Python Client Docs
API Reference: ReadTheDocs - Python Client
Troubleshooting: Community Forum | GitHub Issues
Note: The async client (
WeaviateAsyncClient) is available inweaviate-clientv4.7.0+.
Connection Methods
Three instantiation helpers are provided (docs):
Weaviate Cloud (Recommended)
import weaviate
from weaviate.classes.init import Auth
# Use the official helper function for Weaviate Cloud
client = weaviate.use_async_with_weaviate_cloud(
cluster_url="your-cluster.weaviate.cloud", # Accepts hostname with or without https://
auth_credentials=Auth.api_key("your-api-key"),
headers={ # Note: parameter is "headers" not "additional_headers"
"X-OpenAI-Api-Key": "sk-...",
"X-Anthropic-Api-Key": "sk-ant-...",
}
)
await client.connect() # Required! Async helpers don't auto-connectReference: Weaviate Cloud Setup
Self-Hosted
# For local instances
client = weaviate.use_async_with_local()
# For custom endpoints
client = weaviate.use_async_with_custom(
http_host="localhost",
http_port=8080,
http_secure=False,
grpc_host="localhost",
grpc_port=50051,
grpc_secure=False,
)
await client.connect()Reference: Connection Configuration
Authentication
Multiple authentication modes are supported (docs):
from weaviate.classes.init import Auth
# API Key (most common for Weaviate Cloud)
auth = Auth.api_key("your-api-key")
# Bearer Token (with optional refresh token)
auth = Auth.bearer_token("access-token", refresh_token="refresh-token")
# Client Credentials (OIDC)
auth = Auth.client_credentials(client_secret="secret")
# Client Password (OIDC Resource Owner Password flow)
auth = Auth.client_password(username="user", password="pass")
# Usage
client = weaviate.use_async_with_weaviate_cloud(
cluster_url="your-cluster.weaviate.cloud",
auth_credentials=auth,
)Critical Patterns
⚠️ Connection Lifecycle
Important: Unlike synchronous helpers, async helpers do not connect automatically (docs). You must explicitly call .connect() and .close():
# ❌ Wrong - client not connected
client = weaviate.use_async_with_weaviate_cloud(...)
collections = await client.collections.list_all() # Will fail!
# ✅ Correct - explicit connect/close
client = weaviate.use_async_with_weaviate_cloud(...)
await client.connect()
collections = await client.collections.list_all()
await client.close()⚠️ Sync vs Async Methods
Key distinction (docs): Methods involving server requests are async; local operations are synchronous.
# Collection retrieval is SYNC (no await)
collection = client.collections.get("MyCollection")
# Operations on collections are ASYNC (need await)
config = await collection.config.get()
results = await collection.query.fetch_objects()
count = await collection.aggregate.over_all()Rule: Getting the collection object is sync; calling methods on it is async.
⚠️ Bulk Operations
Important Note (docs): For large-scale data imports, use the synchronous client and its batch operations. The sync client's batch methods already handle concurrency internally and are optimized for bulk operations.
# ✅ For bulk imports, prefer sync client
import weaviate
with weaviate.connect_to_weaviate_cloud(...) as client:
collection = client.collections.get("MyCollection")
# Batch insert handles concurrency automatically
with collection.batch.dynamic() as batch:
for item in large_dataset:
batch.add_object(properties=item)Use the async client for:
Web applications (FastAPI, Starlette)
Concurrent request handling
Interactive queries
Don't use the async client for:
Bulk data imports (use sync client instead)
Context Manager Pattern (Recommended)
Best Practice (docs): Use async with to automatically connect/disconnect:
from contextlib import asynccontextmanager
from typing import AsyncGenerator
@asynccontextmanager
async def get_weaviate_client(
cluster_url: str,
api_key: str,
provider_headers: dict[str, str] | None = None,
) -> AsyncGenerator[weaviate.WeaviateAsyncClient, None]:
"""Connect to Weaviate Cloud with automatic cleanup."""
# Remove scheme if present
hostname = cluster_url.replace("https://", "").replace("http://", "")
client = weaviate.use_async_with_weaviate_cloud(
cluster_url=hostname,
auth_credentials=Auth.api_key(api_key),
headers=provider_headers,
)
try:
await client.connect()
yield client
finally:
await client.close()
# Usage
async def example():
async with get_weaviate_client(
cluster_url="your-cluster.weaviate.cloud",
api_key="your-key",
) as client:
collections = await client.collections.list_all()Note: When using the context manager,
.connect()and.close()are called automatically.
FastAPI Integration
Use Case (docs): The async client excels in web frameworks like FastAPI for handling concurrent requests.
Use lifespan management for shared client across requests:
from fastapi import FastAPI
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup: connect to Weaviate
app.state.weaviate = weaviate.use_async_with_weaviate_cloud(
cluster_url="your-cluster.weaviate.cloud",
auth_credentials=Auth.api_key("your-key"),
)
await app.state.weaviate.connect()
yield
# Shutdown: close connection
await app.state.weaviate.close()
app = FastAPI(lifespan=lifespan)
@app.get("/collections")
async def list_collections():
collections = await app.state.weaviate.collections.list_all()
return {"collections": list(collections.keys())}Community Discussion: FastAPI Best Practices
Common Pitfalls
1. Parameter Name Confusion
# ❌ Wrong - WeaviateAsyncClient() constructor uses different param
client = weaviate.use_async_with_weaviate_cloud(
additional_headers={...} # Wrong parameter name!
)
# ✅ Correct - use "headers" not "additional_headers"
client = weaviate.use_async_with_weaviate_cloud(
headers={...}
)2. URL Format
Both formats work with helper functions:
# ✅ Both accepted
client = weaviate.use_async_with_weaviate_cloud(
cluster_url="https://cluster.weaviate.cloud" # With scheme
)
client = weaviate.use_async_with_weaviate_cloud(
cluster_url="cluster.weaviate.cloud" # Without scheme
)3. Sync vs Async Function Names
# ❌ Wrong - sync client (cannot use await)
client = weaviate.connect_to_weaviate_cloud(...)
await client.connect() # TypeError!
# ✅ Correct - async client
client = weaviate.use_async_with_weaviate_cloud(...)
await client.connect()Naming pattern:
Sync:
connect_to_*(e.g.,connect_to_weaviate_cloud)Async:
use_async_with_*(e.g.,use_async_with_weaviate_cloud)
4. Port Configuration
# ❌ Wrong - manual port config causes conflicts with Weaviate Cloud
client = WeaviateAsyncClient(
connection_params=ConnectionParams.from_url(
url="https://cluster.weaviate.cloud",
grpc_port=443, # Conflict!
)
)
# ✅ Correct - use helper function (handles ports automatically)
client = weaviate.use_async_with_weaviate_cloud(
cluster_url="cluster.weaviate.cloud"
)Rule: For Weaviate Cloud, always use use_async_with_weaviate_cloud() — it handles HTTP (443) and gRPC (50051) ports correctly.
Multi-Cluster Example
Managing connections to multiple Weaviate clusters:
@asynccontextmanager
async def get_multi_cluster_clients(
clusters: dict[str, dict[str, str]]
) -> AsyncGenerator[dict[str, weaviate.WeaviateAsyncClient], None]:
"""Connect to multiple Weaviate clusters.
Args:
clusters: Dict of {cluster_id: {"url": "...", "api_key": "..."}}
"""
clients = {}
try:
# Connect to all clusters
for cluster_id, config in clusters.items():
client = weaviate.use_async_with_weaviate_cloud(
cluster_url=config["url"],
auth_credentials=Auth.api_key(config["api_key"]),
)
await client.connect()
clients[cluster_id] = client
yield clients
finally:
# Close all connections
for client in clients.values():
await client.close()
# Usage
async def example():
clusters = {
"prod": {"url": "prod.weaviate.cloud", "api_key": "key1"},
"dev": {"url": "dev.weaviate.cloud", "api_key": "key2"},
}
async with get_multi_cluster_clients(clusters) as clients:
prod_collections = await clients["prod"].collections.list_all()
dev_collections = await clients["dev"].collections.list_all()Environment Variables
See Environment Requirements for provider API keys.
import os
# Read from environment
cluster_url = os.environ["WEAVIATE_URL"]
api_key = os.environ["WEAVIATE_API_KEY"]
# Build provider headers
provider_headers = {}
if openai_key := os.getenv("OPENAI_API_KEY"):
provider_headers["X-OpenAI-Api-Key"] = openai_key
if anthropic_key := os.getenv("ANTHROPIC_API_KEY"):
provider_headers["X-Anthropic-Api-Key"] = anthropic_key
client = weaviate.use_async_with_weaviate_cloud(
cluster_url=cluster_url,
auth_credentials=Auth.api_key(api_key),
headers=provider_headers or None,
)Testing Async Code
import pytest
@pytest.mark.asyncio
async def test_weaviate_connection():
async with get_weaviate_client(
cluster_url="test-cluster.weaviate.cloud",
api_key="test-key",
) as client:
collections = await client.collections.list_all()
assert isinstance(collections, dict)Quick Reference
| Task | Pattern | Await? |
|---|---|---|
| Create client | weaviate.use_async_with_weaviate_cloud(...) | No |
| Connect | client.connect() | Yes |
| Get collection | client.collections.get("Name") | No |
| List collections | client.collections.list_all() | Yes |
| Query data | collection.query.fetch_objects() | Yes |
| Get config | collection.config.get() | Yes |
| Aggregate | collection.aggregate.over_all() | Yes |
| Close | client.close() | Yes |
Troubleshooting
Common Issues
| Issue | Solution | Reference |
|---|---|---|
| Connection hangs indefinitely | Use context manager or ensure proper .close() | GitHub #753 |
| Multi-worker conflicts (Gunicorn) | Use lifespan management, not startup hooks | GitHub #1292 |
TypeError: object NoneType can't be used in 'await' | Use use_async_with_* not connect_to_* | Async API Docs |
| Port conflicts with Weaviate Cloud | Use helper functions, not manual ConnectionParams | See "Common Pitfalls #4" above |
Getting Help
For agents: When encountering errors:
Check the Common Pitfalls section above
Search Community Forum for similar issues
Check GitHub Issues for known bugs
Refer to official async documentation
Review Python client best practices
Additional Resources
Official Documentation
Primary: Weaviate Async API
Python Client: Main Documentation
API Reference: ReadTheDocs
Best Practices: Notes and Best Practices
Framework Integration
Community
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
What our scanner noticed· Medium risk
- Instructions that use the network
- Downloads piped into a shell
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Weaviate
- Publisher
- Weaviate (Official)
- Source
- weaviate/agent-skills · skills/weaviate-cookbooks · commit b19751c
- Licence
- BSD 3-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Weaviate.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download weaviate-cookbooks.zip