Authentication error using text2-palm

Dear all,

I’m completely a newbie. I would like to configure to use text2vec-palm (Google PaLM instead of open ai, as given in Weaviate’s example). Refer to my code fragments below, I get error when executing in code fragment 3: batch.add_data_object…

My CoLaboratory notebook complains that google authentication is missing, suggesting to provide oauth token etc.

I’m stuck at this point. Grateful if someone can shown you sample code that uses text2vec-palm.

Thanks a lot!

code segment 1 - client config

import weaviate

auth_config = weaviate.AuthApiKey(api_key=“MY_WEAVIATE_KEY”)

client = weaviate.Client(
additional_headers = {

    "X-Palm-Api-Key": "MY_GOOGLE_PROJ_API_KEY"  # Replace with your API key


code fragment 2 - class def.

class_obj = {
“class”: “Question”,

"moduleConfig": {
    "vectorizeClassName": "true",
    "text2vec-palm":  {"projectId": "MY_GOOGLE_PROJ_ID }, # projectId is required
    "generative-palm": { "projectId": "MY_GOOGLE_PROJ_ID" }  # Ensure the `generative-palm` module is used for generative queries, projectId is required



code fragment 3 - add objects

import requests
import json
resp = requests.get(‘MY_DATA.json’)
data = json.loads(resp.text) # Load data

client.batch.configure(batch_size=100) # Configure batch
with client.batch as batch: # Initialize a batch process
for i, d in enumerate(data): # Batch import data
print(f"importing question: {i+1}“)
properties = {
“answer”: d[“Answer”],
“question”: d[“Question”],
“category”: d[“Category”],
print(f"property: {properties}”)


Can you share here the exact error message you got?

Unfortunately I was not able to get my hands on a palm API yet…

The following error message shows in CoLab notebook when running the batch.add_data_object line as in code fragement 3 above. Thanks

{‘error’: [{‘message’: ‘update vector: connection to Google PaLM failed with status: 401 error: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See’}]}