red-television-3815
07/30/2025, 7:10 PMValueError: API key is required for Google API either via api_key or GOOGLE_API_KEY environment variabletall-airline-16756
07/30/2025, 7:10 PMtall-airline-16756
07/30/2025, 7:12 PMValueError: API key is required for Google API either via api_key or GOOGLE_API_KEY environment variable occurs when the Google Gemini API is being used without providing the required API key. However, since you are configuring Vertex AI, this error suggests a misconfiguration.
To configure Vertex AI correctly in LiveKit, follow these steps:
1. Ensure the GOOGLE_APPLICATION_CREDENTIALS environment variable is set to the path of your service account key file:
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"
1. Optionally, set the following environment variables for your project and location:
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="us-central1"
1. To ensure Vertex AI is used, set the GOOGLE_GENAI_USE_VERTEXAI environment variable:
export GOOGLE_GENAI_USE_VERTEXAI="true"
Here is an example of how to configure the Google LLM in LiveKit for Vertex AI:
from livekit.plugins import google
google_llm = google.LLM(
model="gemini-2.0-flash-001",
vertexai=True,
project="your-gcp-project-id", # optional if set via env var
location="us-central1" # optional, defaults to us-central1
)
By following these steps, the configuration should work without requiring an API key, as Vertex AI uses Google Cloud authentication via the service account credentials.
If you still encounter issues, double-check the environment variable values and ensure the service account has the necessary permissions for Vertex AI.
Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py