Here is the code I ran, based on Gemini Batch API now supports Embeddings and OpenAI Compatibility - Google Developers Blog
import json
from google import genai
import os
import boto3
os.environ["GEMINI_API_KEY"] = get_api_key()
client = genai.Client()
uploaded_batch_requests = client.files.upload(file='my_file', config={'mime_type': 'application/jsonl'})
batch_job = client.batches.create_embeddings(
model="gemini-embedding-001",
src={"file_name": uploaded_batch_requests.name}
)
and here is the error I received, although it is not that helpful, since this was the first request I ran in over a month
google.genai.errors.ClientError: 429 RESOURCE_EXHAUSTED. {'error': {'code': 429, 'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, head to: https://ai.google.dev/gemini-api/docs/rate-limits. To monitor your current usage, head to: https://ai.dev/rate-limit. ', 'status': 'RESOURCE_EXHAUSTED', 'details': [{'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Learn more about Gemini API quotas', 'url': 'https://ai.google.dev/gemini-api/docs/rate-limits'}]}]}}
I used to use this endpoint heavily, and I now can’t seem to do anything with it. All my usage is basically at zero.
my friend was able to run exactly the same code with a different api key successfully. Any help is appreciated.