I’m trying to use Google’s text vectorizer (text2vec_google) with Weaviate Cloud but encountering authentication issues. Despite providing the Google API key in headers, I’m getting a 401 error indicating invalid authentication credentials.
Environment
Weaviate Cloud instance
Python client v4
Using Google AI Studio API key
Code
import weaviate
import weaviate.classes as wc
from weaviate.classes.config import Property, DataType
# Connect to Weaviate
google_api_key = "my-google-api-key" # Actual key removed
headers = {
"X-Goog-Studio-Api-Key": google_api_key, # Also tried X-Goog-Api-Key, X-Palm-Api-Key
}
weaviate_url = "https://my-instance.weaviate.cloud"
weaviate_api_key = "my-weaviate-api-key" # Actual key removed
client = weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url,
auth_credentials=weaviate.auth.AuthApiKey(weaviate_api_key),
headers=headers
)
# Create collection with Google vectorizer
client.collections.create(
name="KnowledgeUnit",
properties=[
wc.config.Property(name="chunks", data_type=wc.config.DataType.TEXT)
],
vectorizer_config=wc.config.Configure.Vectorizer.text2vec_google(
project_id="t1",
model_id="textembedding-gecko@latest"
)
)
Error message:
Google API Key: no api key found neither in request header: X-Palm-Api-Key or X-Goog-Api-Key or X-Goog-Vertex-Api-Key or X-Goog-Studio-Api-Key nor in environment variable under PALM_APIKEY or GOOGLE_APIKEY
What I've tried
Using different header formats: X-Goog-Api-Key, X-Goog-Studio-Api-Key.
Questions:
What is the correct header name to use for Google AI Studio API keys?
Is there a specific format required for the API key?