text2vec-openai and generative-openai modules accept a baseURL, which is the documented route to any OpenAI-compatible endpoint. Pointing both at a SambaStack instance lets Weaviate embed your data and answer questions with SambaNova models.
Prerequisites
- A SambaStack instance that serves
E5-Mistral-7B-Instruct, plus the instance’s base URL and API key. See API keys and URLs. - A chat model on that instance. This guide uses
gpt-oss-120b. - A running Weaviate server, or a Weaviate Cloud cluster. To run one locally, follow the Weaviate Docker installation guide.
- Network access from the Weaviate server to your SambaStack instance. The Weaviate server calls SambaStack, not your Python code, so a Weaviate Cloud cluster cannot reach a SambaStack instance on a private network.
- Python 3.10 or higher.
text2vec-openai and generative-openai modules must be enabled on your Weaviate server. Weaviate Cloud enables them by default. On a self-hosted server, open /v1/meta and check that both appear under modules. If they do not, enable them with the ENABLE_MODULES environment variable, as described in Weaviate’s module configuration guide.
Installation and setup
Create a virtual environment
Install dependencies
weaviate-client 4.24.1 and Weaviate 1.40.1.Set your SambaStack base URL and API key
/v1 to the base URL here. Weaviate appends /v1/embeddings and /v1/chat/completions itself, so a base URL that already ends in /v1 produces a 404.Configure the modules and query
Run the steps in this section in one Python file or session. Each step uses variables from the steps before it.Connect to Weaviate
X-OpenAI-Api-Key header.connect_to_local connects to a server on localhost. For Weaviate Cloud, set WEAVIATE_URL to your cluster URL and WEAVIATE_API_KEY to your cluster’s API key, then connect with connect_to_weaviate_cloud and the same headers:Create a collection that uses SambaNova
base_url on both modules, and name the SambaNova models. Weaviate reads the vector size from the model, so you do not set a dimension.SambaNovaDemo collection already exists, the code deletes it first, so each run starts with a clean collection.text2vec_openai handles embeddings and Generative.openai handles chat completions. Weaviate calls SambaNova from the server, so the SambaStack instance must be reachable from where Weaviate runs.Add your documents
Search by meaning
Answer with a SambaNova chat model
Delete the collection and close the connection
Use Weaviate with SambaCloud
SambaCloud does not serve embeddings, so embed the text yourself with a local model and let Weaviate’s generative module call SambaCloud for answers. Install FastEmbed, and setSAMBANOVA_BASE_URL to https://api.sambanova.ai.
Additional resources
Weaviate documentation
OpenAI embeddings in Weaviate
text2vec-openai module and its parameters.OpenAI generative AI in Weaviate
generative-openai module and its parameters.Implement embeddings features
Troubleshooting
KeyError: 'SAMBANOVA_BASE_URL'
KeyError: 'SAMBANOVA_BASE_URL'
SAMBANOVA_BASE_URL or SAMBANOVA_API_KEY. Set it as shown in Installation and setup, then run the code again from the same shell. For Weaviate Cloud, also set WEAVIATE_URL and WEAVIATE_API_KEY.failed to parse vectorization response (status 404)
failed to parse vectorization response (status 404)
/v1. Weaviate adds /v1/embeddings to the base URL, so it ends up calling /v1/v1/embeddings. Set base_url to your SambaStack base URL without /v1, then recreate the collection.API Key: no api key found neither in request header: X-Openai-Api-Key
API Key: no api key found neither in request header: X-Openai-Api-Key
headers={"X-OpenAI-Api-Key": ...} to connect_to_local or connect_to_weaviate_cloud, and check that SAMBANOVA_API_KEY is exported in the shell you run Python from.connection to: OpenAI API failed with status: 401
connection to: OpenAI API failed with status: 401
connection to: OpenAI API failed with status: 404 ... model does not exist
connection to: OpenAI API failed with status: 404 ... model does not exist
422: class name SambaNovaDemo already exists
422: class name SambaNovaDemo already exists
SambaNovaDemo collection first. If you removed that check, delete it with client.collections.delete("SambaNovaDemo").
