Can't connect to Google Vertex

I get Google API Key: no api key found neither in request header even though I am hard coding in the urls and keys as shown below. I also ran gcloud auth print-access-token within the last hour and that is the key I am using.

weaviate_url = "a_url"
weaviate_key = "a_key"
vertex_key = "a_key"
headers = {
    "X-Google-Vertex-Api-Key": vertex_key,
}

client = weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,                       # `weaviate_url`: your Weaviate URL
    auth_credentials=Auth.api_key(weaviate_key),      # `weaviate_key`: your Weaviate API key
    headers=headers)

collection = client.collections.get("Testing")
with collection.batch.dynamic() as batch:
    for src_obj in source_objects:
        image_b64 = url_to_base64(src_obj["image_path"])
        weaviate_obj = {
            "image": image_b64,
            "source": src_obj["source"],
        }

        # The model provider integration will automatically vectorize the object
        batch.add_object(
            properties=weaviate_obj,
            # vector=vector  # Optionally provide a pre-obtained vector
        )
        break

failed_objects = collection.batch.failed_objects # After batch is done

hi!

What is the version of the client?

Also, can you paste the full error stack trace?

Thanks!

The weaviate version is 1.25.9
The weaviate client is 4.7.1

{‘message’: ‘Failed to send 1 objects in a batch of 1. Please inspect client.batch.failed_objects or collection.batch.failed_objects for the failed objects.’}

[ErrorObject(message=“WeaviateInsertManyAllFailedError(‘Every object failed during insertion. Here is the set of all errors: Google API Key: no api key found neither in request header: X-Palm-Api-Key or X-Google-Api-Key or X-Google-Vertex-Api-Key or X-Google-Studio-Api-Key nor in environment variable under PALM_APIKEY or GOOGLE_APIKEY’)”

Hi @Cobyboss,

I think there is a bug with the multimodal models and the Vertex header.

Can you try using “X-Palm-Api-Key” instead?

headers = {
    "X-Palm-Api-Key": vertex_key,
}

Should I use Google Palm too or can I just use that header with the same vertex_key?

You can definitely use the same header with the vertex_key, no problem there.

I am faced with the same problem, but using X-Palm-Api-Key does not seem to work.

Vertex AI is not compatible with API Keys anymore, hence I am trying Oauth2, service acc or simply an access token.

EDIT: It now uploads the properties, but does not vectorize.

My cluster is 1.25.10 and my python dependency client is 4.7.1.

I am basically running these lines

client = weaviate.connect_to_weaviate_cloud(
    cluster_url=os.getenv("WEAVIATE_URL"),
    auth_credentials=weaviate.auth.AuthApiKey(api_key=os.getenv("WEAVIATE_API_KEY")),
    headers={"X-OpenAI-Api-Key": os.getenv("OPENAI_API_KEY"),
             # "X-Google-Vertex-Api-Key": os.getenv("GOOGLE_ACCESS_TOKEN"),
             "X-Palm-Api-Key": os.getenv("GOOGLE_ACCESS_TOKEN")
             }
)

for q in tqdm(collection_src.iterator()):
     collection_tgt.data.insert(properties=q.properties, uuid=q.uuid)