How do I get credentials to integrate google' clou...
# ask-ai
p
How do I get credentials to integrate google' cloud TTS in livekit ?
t
Thanks for reaching out, Shriniket. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I can help with that. You're asking how to get credentials to integrate Google Cloud Text-to-Speech (TTS) with LiveKit. Follow these steps: 1. Create or select a Google Cloud project in the Google Cloud Console: https://console.cloud.google.com/ 2. Enable the Cloud Text-to-Speech API for that project. 3. Create a service account: IAM & Admin → Service Accounts → Create Service Account. Assign a role such as "Text-to-Speech User" (or another role with TTS access). 4. Create and download a JSON key for that service account: select the account → Keys → Add Key → Create new key → JSON. Store this file securely. 5. Provide the credentials to your LiveKit agent environment: ◦ Set
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON key file, or ◦ Export an appropriate API key if you prefer
GOOGLE_API_KEY
. Example:
Copy code
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
1. Install and configure the LiveKit Google plugin (if using LiveKit Agents):
Copy code
pip install "livekit-agents[google]"
Then initialize the Google TTS plugin in your agent code (the plugin will use the environment credentials). If you want, tell me: • which language/runtime you’re using (Python, Node, etc.), and • whether you’ll run LiveKit Agents server-side or in a specific deployment (so I can give exact code snippets and env var examples). Sources: An open source stack for real-time multimodal AI | Gemini Realtime Agent with Live Vision | LiveKit docs
p
is there any other way apat froms service account, as google says it's riskt
t
Good question — you don't have to use a downloaded service-account key file. Options that avoid long‑lived key files: • Workload Identity Federation (recommended): lets your LiveKit agent obtain short‑lived Google credentials from an external IdP (AWS, Azure, OIDC) without ever storing a JSON key. Use this if your agent runs outside GCP. • Run on GCP with an attached service account: deploy the agent to Cloud Run, GKE, or Compute Engine and assign a service account to the instance. No key file required and Google client libraries pick up credentials automatically. • Service account impersonation with least privilege: avoid broad permissions by creating a low‑privilege service account and have a short‑lived principal impersonate it (combine with workload identity where possible). Not viable for LiveKit TTS: • API keys — Google Cloud TTS does not support API‑key authentication. • User OAuth (3‑legged) — impractical for unattended backend agents. If you tell me where you run your LiveKit agent (AWS, Azure, on‑prem, or GCP) I can give exact setup steps for Workload Identity Federation or for attaching a GCP service account to your deployment. Sources: examples/voice_agents | livekit/livekit_composite | DeepWiki | Gemini Realtime Agent with Live Vision | LiveKit docs | TTS Comparison | LiveKit docs
p
it's on AWS
t
Great — since you're on AWS, the safest option is Workload Identity Federation so your LiveKit agent can get short‑lived Google credentials without a JSON key file. Below are concise steps you can follow. 1. Create a Google Cloud service account • In Google Cloud Console, create a service account with only the TTS permissions it needs. 1. Create a Workload Identity Pool & Provider (GCP) • In IAM → Workload Identity Pools, create a pool (e.g., livekit-pool). • Add an OIDC provider that trusts AWS STS. Use the provider type “AWS” or OIDC with AWS as the issuer; note the provider requires your AWS account ID and the AWS role's ARN you’ll create next. 1. Create an AWS IAM role for your LiveKit agent • In AWS IAM, create a role assumed by AWS services where your agent runs (EC2, ECS task, or EKS service account). • Add a trust relationship allowing sts:AssumeRoleWithWebIdentity or the AWS principal to assume the role from your workload identity provider. • Attach any minimal AWS policies needed for your deployment (not for GCP access). 1. Allow GCP service account to be impersonated • In GCP IAM, grant the Workload Identity Pool (or the specific provider) the permission to impersonate the service account: ◦ Grant the role
roles/iam.workloadIdentityUser
on the service account to the AWS principal identifier in the pool (format provided by GCP when you create the provider). 1. Configure your LiveKit agent to fetch tokens • Use Google Cloud client libraries which support Workload Identity Federation. • Instead of
GOOGLE_APPLICATION_CREDENTIALS
, configure the federation by setting environment variables or a credentials config that points to your workload identity pool and provider. The libraries will exchange AWS STS tokens for short‑lived Google access tokens. 1. Verify TTS calls • Run the agent and confirm application calls to Cloud TTS succeed. The Google library should show it’s using federated credentials (short‑lived). If you want, I can provide: • Exact IAM trust JSON and example AWS role policy for your runtime (ECS, EC2, or EKS). • The exact `gcloud`/console commands or the JSON config snippet to set up the Workload Identity Provider and bind
roles/iam.workloadIdentityUser
. Which runtime are you using on AWS (EC2, ECS/Fargate, or EKS)?