Google Studio Api Key problem

Tried with this setup
import weaviate

from weaviate.classes.init import Auth

import os

jinaai_key = os.getenv(“JINAAI_APIKEY”)

studio_key = os.getenv(“GOOGLE_APIKEY”)

weaviate_url = os.getenv(“WEAVIATE_URL”)

weaviate_key = os.getenv(“WEAVIATE_API_KEY”)

headers = {

"X-Goog-Studio-Api-Key": studio_key,

"X-JinaAI-Api-Key": jinaai_key,

}

client = weaviate.connect_to_weaviate_cloud(

cluster_url=weaviate_url,

auth_credentials=Auth.api_key(weaviate_key),

headers=headers

)

print(client.is_ready())
And got a problem while inserting :
{‘message’: ‘Failed to send all objects in a batch of 7’, ‘error’: “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-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 should I do ?

Good morning @Zakaryae_Bennani,

Welcome to our community, it’s lovely to have you here with us.

Could you please let me know which version of Weaviate DB you’re using?

Additionally, could you share your vectorizer settings for the collection?

Best regards,

Mohamed Shahin
Weaviate Support Engineer
(Ireland, UTC±00:00/+01:00)

Good morning @Mohamed_Shahin ,

Thank you for your reply and your kind welcome, my Weaviate version is 1.32.9.

Besides, here you are my vectorizer settings:

vector_config = [

    Configure.Vectors.text2vec_google(

                name="vector", 

                source_properties=['formatted_page'],

                vectorize_collection_name = False,

                model="text-multilingual-embedding-002",

                project_id=os.getenv("GOOGLE_CLOUD_PROJECT"),

                vector_index_config=Configure.VectorIndex.hnsw(),

                )

            ]
# While creating the collection:
    collection = client.collections.create(

            name='cri_collection',

            vector_config=vector_config,
            
            #the rest of the conf.........

)

Best regards,

I’ve tested this using the exact same setup as yours with my Google API key, and it works fine on my side.

Could you try checking whether your headers are actually being passed by printing them out with:

from weaviate.classes.init import Auth
import os, weaviate

studio_key = "<My_TEST_Data>"
weaviate_url = "<My_TEST_Data>"
weaviate_key = "<My_TEST_Data>"

headers = {
    "X-Goog-Studio-Api-Key": studio_key,
}

client = weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=Auth.api_key(weaviate_key),
    headers=headers
)

ready = client.is_ready()
server_version = client.get_meta()["version"]
client_version = weaviate.__version__
live = client.is_live()
connected = client.is_connected()

print(f"Weaviate Ready: {ready}")
print(f"Weaviate Client Version: {client_version}")
print(f"Weaviate Server Version: {server_version}")
print("Headers passed:")
print(client._connection._headers)

If the headers don’t print, or API appears to be missing, then the issue is on your end somewhere.

Best regards,

Mohamed Shahin
Weaviate Support Engineer
(Ireland, UTC±00:00/+01:00)

The problem occurs while inserting the data in the database.

            for chunk_obj in tqdm(chunk_objs_list, desc=f"Processing {json_file}"):
                    uuid = generate_uuid5(chunk_obj)
                    batch.add_object(
                        properties=chunk_obj,
                        uuid=uuid,
                    )
the error:
{'message': 'Failed to send all objects in a batch of 5', 'error': "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-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')"}
{'message': 'Failed to send 5 objects in a batch of 5. Please inspect client.batch.failed_objects or collection.batch.failed_objects for the failed objects.'}

I understand. I’m checking with you whether the headers are being passed correctly when you connect to the Weaviate client with the cluster.

On my side, I’m able to ingest data with the Google vectorizer and can’t reproduce the issue, so something unusual is happening. I’m trying to narrow it down from your end.

all right, I got you, I will try with the provided code and share the results

1 Like

Hello, I tried with the code and all the headers are being passed correctly :

Weaviate Ready: True

Weaviate Client Version: 4.16.10

Weaviate Server Version: 1.32.9

Headers passed:

{

‘content-type’: ‘application/json’,

‘X-Weaviate-Cluster-URL’: ‘the key is successfully passed’,

‘X-Weaviate-Api-Key’: ‘the key is successfully passed’,

‘x-goog-studio-api-key’: ‘the key is successfully passed’,

‘x-jinaai-api-key’:‘the key is successfully passed’,

‘authorization’: 'Bearer MDdvWlVUZHdY………’

}

Best regards.

That’s unusual. Are you running Weaviate locally or in our cloud?

If it’s a local deployment, could you share the full files of ingesting and creating schema (take our your keys - I will add mine from testing evn) and deployment setup with me? If it’s on our cloud, I can access it internally. I’ll mirror everything exactly as you have it, including the deployment.