AI-assisted Weaviate code generation
Generative AI models are becoming more capable at writing code. This practice is often referred to as "vibe-coding" or "AI-assisted coding". While this can speed up development, it is also subject to some pitfalls, such as hallucinations due to out-of-date, or missing information in the training data.
Here are some tips for writing Weaviate client library code with generative AI models and tooling, based on our anecdotal experience.

Specific recommendations
Section titled “Specific recommendations”Weaviate MCP Servers
Section titled “Weaviate MCP Servers”Weaviate provides two MCP servers that integrate with AI development tools like Claude Code, Claude Desktop, Cursor, and VS Code:
- Weaviate MCP Server: Built into Weaviate itself. Lets AI assistants inspect schemas, search data, and modify objects in your Weaviate instance directly. Enable with
MCP_SERVER_ENABLED=true. - Weaviate Docs MCP Server: A standalone server that gives AI assistants access to Weaviate's documentation, reducing hallucinations when generating Weaviate code.
Weaviate Agent Skills
Section titled “Weaviate Agent Skills”Weaviate Agent Skills gives AI coding agents (Claude Code, Cursor, GitHub Copilot, and others) built-in knowledge of Weaviate, covering search, collection management, data import, and complete application blueprints such as RAG, agentic RAG, and chatbots. When the skill is installed, agents can discover and use it automatically, reducing hallucinations and speeding up Weaviate development.
Install with:
npx skills add weaviate/agent-skillsHigh-performing models
Section titled “High-performing models”As of July 2025, we've seen these models perform well for code generation. (Assessed by the correctness of generated Python v4 client library code.)
- Anthropic
claude-sonnet-4-20250514 - Google
gemini-2.5-pro - Google
gemini-2.5-flash
If you are using the Python client library, we recommend that you try out one of the above models to see if it performs well for your use case.
Although none of these models performed perfectly at zero-shot code generation tasks (i.e. with only a description of the task), they were able to generate correct code most of the time when provided with in-context examples.
In-context code examples
Section titled “In-context code examples”We found that performances of the above LLMs improved significantly when provided with in-context examples. We suggest that you can get better results by providing in-context examples relevant to the task you are trying to accomplish.
As a starting point, we have curated a set of code examples below. Try copy and pasting this block of code into your prompt.
{CodeExamples}If the above code examples are not sufficient, you can try the following:
- Collect code examples from relevant sections of the Weaviate Documentation.
- Use the
Ask AIfeature in the Weaviate Documentation to find examples of how to perform specific tasks. Then, use the provided code in your prompt.
General tips
Section titled “General tips”Along with the specific recommendations above, we also have the following general tips:
Use the latest models
Section titled “Use the latest models”You may already have a preferred model provider. Try out the latest models to see if they perform better for your use case.
Later models will be trained on more recent data, and are likely to be better at zero-shot code generation tasks. This is particularly important where the code base has been significantly updated, such as with the Weaviate Python client, which was rewritten in 2024.
Look for better instruction-following models
Section titled “Look for better instruction-following models”Some models are better at following instructions provided as in-context examples.
These models are more likely to respect up-to-date examples provided as in-context instructions.
Review the generated code for signs of hallucination
Section titled “Review the generated code for signs of hallucination”It is important to review the generated code for signs of hallucination.
For the Weaviate Python client, a telltale sign of hallucination, or out-of-date code is the use of weaviate.Client class for connecting to Weaviate. This was used in the older, v3 version of the client library and is not present in the v4 version.
The latest version of the Weaviate Python client uses weaviate.connect_to_xyz() helper functions to connect to Weaviate, using the WeaviateClient class.
Index further documentation
Section titled “Index further documentation”Some AI-powered code generation tools such as Cursor allow you to index further documentation. This can be a great way to get more context for the code generation task. Then, you could prompt the IDE to generate code based on the indexed documentation.
Review the documentation of your specific IDE to see if it has this feature, and how to use it.
Consider using the Query Agent
Section titled “Consider using the Query Agent”The Query Agent is a pre-built agentic search service that decides the search terms, filters, sorts, and other search parameters for you. The modes overview covers what it can do.
The Query Agent is available to Weaviate Cloud users for interacting with their Weaviate Cloud instance in natural language. For some use cases, this may be a better approach than using AI-powered code generation tools.
Help us improve this page
Section titled “Help us improve this page”The above recommendations are based on our experience using generative AI models for code generation.
In order to collect data for this page in a systematic way, we ran a series of evaluations through this repository.
The test were carried out by generating code for the Weaviate Python client v4 using various LLMs, and assessing whether the code was able to run successfully. Each task was carried out multiple times, once as a zero-shot task, and at least once with in-context examples.
A sampling of the results are collected in this directory.
Please note that this was a small-scale evaluations for providing guidelines only. If you are interested in running your own evaluations, please check out the repository.
If you have any questions or feedback, please let us know by opening an issue on GitHub.
Questions and feedback
Section titled “Questions and feedback”Have a question or feedback? Here's how to reach us.