|
| 1 | +--- |
| 2 | +title: Generative AI |
| 3 | +description: "Weaviate's integration with DeepSeek's API allows you to access their generative models' capabilities directly from Weaviate." |
| 4 | +sidebar_position: 50 |
| 5 | +image: og/docs/model-provider-integrations.jpg |
| 6 | +# tags: ['model providers', 'deepseek', 'generative', 'rag'] |
| 7 | +--- |
| 8 | + |
| 9 | +# DeepSeek Generative AI with Weaviate |
| 10 | + |
| 11 | +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; |
| 12 | +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; |
| 13 | +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; |
| 14 | + |
| 15 | +Weaviate's integration with DeepSeek's API allows you to access their generative models' capabilities directly from Weaviate. |
| 16 | + |
| 17 | +[Configure a Weaviate collection](#configure-collection) to use a generative AI model with DeepSeek. Weaviate will perform retrieval augmented generation (RAG) using the specified model and your DeepSeek API key. |
| 18 | + |
| 19 | +More specifically, Weaviate will perform a search, retrieve the most relevant objects, and then pass them to the DeepSeek generative model to generate outputs. |
| 20 | + |
| 21 | +:::info Code examples are Python-only for now |
| 22 | +This page currently shows Python examples only. The typed builder syntax shown below (`Configure.Generative.deepseek()`) is the intended Python client API; client support is being implemented to match it. Other client languages will be added once the corresponding client support ships. |
| 23 | +::: |
| 24 | + |
| 25 | +## Requirements |
| 26 | + |
| 27 | +### Weaviate configuration |
| 28 | + |
| 29 | +Your Weaviate instance must be configured with the DeepSeek generative AI integration (`generative-deepseek`) module. |
| 30 | + |
| 31 | +:::info Added in `v1.36.19`, `v1.37.10`, and `v1.38.2` |
| 32 | +The `generative-deepseek` module was added as a coordinated backport across the `v1.36`, `v1.37`, and `v1.38` release lines. It is available from `v1.36.19` (on the `v1.36` line), `v1.37.10` (on the `v1.37` line), and `v1.38.2` (on the `v1.38` line). Earlier patch releases on these lines do not include the module. |
| 33 | +::: |
| 34 | + |
| 35 | +<details> |
| 36 | + <summary>For Weaviate Cloud (WCD) users</summary> |
| 37 | + |
| 38 | +This integration is enabled by default on Weaviate Cloud (WCD) instances. |
| 39 | + |
| 40 | +</details> |
| 41 | + |
| 42 | +<details> |
| 43 | + <summary>For self-hosted users</summary> |
| 44 | + |
| 45 | +- Check the [cluster metadata](/deploy/configuration/status.md#cluster-metadata) to verify if the module is enabled. |
| 46 | +- Follow the [how-to configure modules](../../configuration/modules.md) guide to enable the module in Weaviate. |
| 47 | +- To enable the module, include it in the `ENABLE_MODULES` environment variable available to Weaviate, e.g. `ENABLE_MODULES="generative-deepseek"` (add it to your existing comma-separated list if other modules are enabled). |
| 48 | + |
| 49 | +</details> |
| 50 | + |
| 51 | +### API credentials |
| 52 | + |
| 53 | +You must provide a valid DeepSeek API key to Weaviate for this integration. Go to [DeepSeek](https://platform.deepseek.com/) to sign up and obtain an API key. |
| 54 | + |
| 55 | +Provide the API key to Weaviate using one of the following methods: |
| 56 | + |
| 57 | +- Set the `DEEPSEEK_APIKEY` environment variable that is available to Weaviate. |
| 58 | +- Provide the API key at runtime, as shown in the examples below. |
| 59 | + |
| 60 | +<FilteredTextBlock |
| 61 | + text={PyConnect} |
| 62 | + startMarker="# START DeepseekInstantiation" |
| 63 | + endMarker="# END DeepseekInstantiation" |
| 64 | + language="py" |
| 65 | +/> |
| 66 | + |
| 67 | +## Configure collection |
| 68 | + |
| 69 | +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; |
| 70 | + |
| 71 | +<MutableGenerativeConfig /> |
| 72 | + |
| 73 | +[Configure a Weaviate index](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration) as follows to use a DeepSeek generative model: |
| 74 | + |
| 75 | +<FilteredTextBlock |
| 76 | + text={PyCode} |
| 77 | + startMarker="# START BasicGenerativeDeepseek" |
| 78 | + endMarker="# END BasicGenerativeDeepseek" |
| 79 | + language="pyindent" |
| 80 | +/> |
| 81 | + |
| 82 | +### Select a model |
| 83 | + |
| 84 | +You can specify one of the [available models](#available-models) for Weaviate to use, as shown in the following configuration example: |
| 85 | + |
| 86 | +<FilteredTextBlock |
| 87 | + text={PyCode} |
| 88 | + startMarker="# START GenerativeDeepseekCustomModel" |
| 89 | + endMarker="# END GenerativeDeepseekCustomModel" |
| 90 | + language="pyindent" |
| 91 | +/> |
| 92 | + |
| 93 | +You can [specify](#generative-parameters) one of the [available models](#available-models) for Weaviate to use. The [default model](#available-models) is used if no model is specified. |
| 94 | + |
| 95 | +### Generative parameters |
| 96 | + |
| 97 | +Configure the following generative parameters to customize the model behavior. |
| 98 | + |
| 99 | +<FilteredTextBlock |
| 100 | + text={PyCode} |
| 101 | + startMarker="# START FullGenerativeDeepseek" |
| 102 | + endMarker="# END FullGenerativeDeepseek" |
| 103 | + language="pyindent" |
| 104 | +/> |
| 105 | + |
| 106 | +For further details on model parameters, see the [DeepSeek API documentation](https://api-docs.deepseek.com/). |
| 107 | + |
| 108 | +## Select a model at runtime |
| 109 | + |
| 110 | +Aside from setting the default model provider when creating the collection, you can also override it at query time. |
| 111 | + |
| 112 | +<FilteredTextBlock |
| 113 | + text={PyCode} |
| 114 | + startMarker="# START RuntimeModelSelectionDeepseek" |
| 115 | + endMarker="# END RuntimeModelSelectionDeepseek" |
| 116 | + language="pyindent" |
| 117 | +/> |
| 118 | + |
| 119 | +## Header parameters |
| 120 | + |
| 121 | +You can provide the API key as well as some optional parameters at runtime through additional headers in the request. The following headers are available: |
| 122 | + |
| 123 | +- `X-Deepseek-Api-Key`: The DeepSeek API key. |
| 124 | +- `X-Deepseek-Baseurl`: The base URL to use (e.g. a proxy) instead of the default DeepSeek URL. |
| 125 | + |
| 126 | +These headers are case-insensitive on the wire. Any additional headers provided at runtime will override the existing Weaviate configuration. |
| 127 | + |
| 128 | +Provide the headers as shown in the [API credentials examples](#api-credentials) above. |
| 129 | + |
| 130 | +## Retrieval augmented generation |
| 131 | + |
| 132 | +After configuring the generative AI integration, perform RAG operations, either with the [single prompt](#single-prompt) or [grouped task](#grouped-task) method. |
| 133 | + |
| 134 | +### Single prompt |
| 135 | + |
| 136 | +To generate text for each object in the search results, use the single prompt method. |
| 137 | + |
| 138 | +The example below generates outputs for each of the `n` search results, where `n` is specified by the `limit` parameter. |
| 139 | + |
| 140 | +When creating a single prompt query, use braces `{}` to interpolate the object properties you want Weaviate to pass on to the language model. For example, to pass on the object's `title` property, include `{title}` in the query. |
| 141 | + |
| 142 | +<FilteredTextBlock |
| 143 | + text={PyCode} |
| 144 | + startMarker="# START SinglePromptExample" |
| 145 | + endMarker="# END SinglePromptExample" |
| 146 | + language="py" |
| 147 | +/> |
| 148 | + |
| 149 | +### Grouped task |
| 150 | + |
| 151 | +To generate one text for the entire set of search results, use the grouped task method. |
| 152 | + |
| 153 | +In other words, when you have `n` search results, the generative model generates one output for the entire group. |
| 154 | + |
| 155 | +<FilteredTextBlock |
| 156 | + text={PyCode} |
| 157 | + startMarker="# START GroupedTaskExample" |
| 158 | + endMarker="# END GroupedTaskExample" |
| 159 | + language="py" |
| 160 | +/> |
| 161 | + |
| 162 | +## References |
| 163 | + |
| 164 | +### Available models |
| 165 | + |
| 166 | +Weaviate forwards the configured model name to DeepSeek as-is; there is no allowlist on the Weaviate side, so any current DeepSeek model id is accepted. We recommend setting `model` explicitly to one of the current models: |
| 167 | + |
| 168 | +* `deepseek-v4-flash` (recommended; verified with this integration) |
| 169 | +* `deepseek-v4-pro` |
| 170 | + |
| 171 | +The module's built-in default model is `deepseek-chat`. |
| 172 | + |
| 173 | +:::caution Legacy model aliases scheduled for deprecation |
| 174 | +According to [DeepSeek's pricing page](https://api-docs.deepseek.com/quick_start/pricing), `deepseek-chat` and `deepseek-reasoner` are legacy aliases scheduled for deprecation on **2026-07-24**, and they currently map to `deepseek-v4-flash` (in non-thinking and thinking modes, respectively). To avoid disruption, set `model` explicitly to a current `deepseek-v4-*` model id rather than relying on the default. |
| 175 | +::: |
| 176 | + |
| 177 | +:::note Reasoning output is not returned |
| 178 | +The `generative-deepseek` module returns only the model's message content. If you use a reasoning/thinking model, the separate reasoning (chain-of-thought) output is not surfaced through the integration. |
| 179 | +::: |
| 180 | + |
| 181 | +For the full list of models and pricing, see the [DeepSeek pricing page](https://api-docs.deepseek.com/quick_start/pricing) and the [DeepSeek API documentation](https://api-docs.deepseek.com/). |
| 182 | + |
| 183 | +## Further resources |
| 184 | + |
| 185 | +### Code examples |
| 186 | + |
| 187 | +Once the integration is configured at the collection, the data management and search operations in Weaviate work identically to any other collection. See the following model-agnostic examples: |
| 188 | + |
| 189 | +- The [How-to: Manage collections](../../manage-collections/index.mdx) and [How-to: Manage objects](../../manage-objects/index.mdx) guides show how to perform data operations (i.e. create, read, update, delete collections and objects within them). |
| 190 | +- The [How-to: Query & Search](../../search/index.mdx) guides show how to perform search operations (i.e. vector, keyword, hybrid) as well as retrieval augmented generation. |
| 191 | + |
| 192 | +### References |
| 193 | + |
| 194 | +- [DeepSeek API documentation](https://api-docs.deepseek.com/) |
| 195 | + |
| 196 | +## Questions and feedback |
| 197 | + |
| 198 | +import DocsFeedback from '/_includes/docs-feedback.mdx'; |
| 199 | + |
| 200 | +<DocsFeedback/> |
0 commit comments