How to Get a Google Text to Speech API Key (Step by Step)

To get a Google text to speech API key, open the Google Cloud console, pick or create a project, link a billing account, and enable the Cloud Text-to-Speech API. Then go to APIs & Services > Credentials, click Create credentials > API key, and restrict the key to the Cloud Text-to-Speech API. Most voice types include a monthly free tier, so small tests usually cost nothing.
Before you start, check what your plugin or app actually asks for. Some tools want an API key string, while others (including AtlasVoice Pro for WordPress) want a service account JSON key file instead. This guide covers both, plus pricing, a curl test, security tips and the errors you are most likely to see.
What you need before you start
- A Google account that can sign in to the Google Cloud console (opens in a new tab).
- A payment method for a Cloud Billing account. Google's setup guide says you must enable billing to use the Cloud Text-to-Speech API, but you won't be charged unless you go over the free quota.
How to get a Google text to speech API key, step by step
These steps follow Google's official Get started with Cloud Text-to-Speech (opens in a new tab) and Manage API keys (opens in a new tab) pages.
1. Create or select a project
Sign in to the Google Cloud console and open the project selector. Choose an existing project or create a new one. A separate project just for text to speech keeps billing easy to track.
2. Link a billing account
If you create a new project, the console prompts you to link a billing account. If you reuse an existing project, confirm that billing is enabled for it. Without billing, requests fail even if you stay inside the free tier.
3. Enable the Cloud Text-to-Speech API
Type "speech" in the search bar at the top of the console, select Cloud Text-to-Speech API from the results, and click Enable.
4. Create the API key
- Go to APIs & Services > Credentials.
- Click Create credentials and choose API key.
- Add at least one restriction. In the console, at least one API restriction is required to create a key.
- Click Create and copy the key string from the dialog.
The same dialog offers a checkbox to bind the key to a service account (Google calls that an "authorization key"). You don't need it for a standard text to speech setup, so leave it unticked.
5. Restrict the key
Google warns that unrestricted API keys are insecure and recommends setting both kinds of restriction:
- API restriction: under API restrictions, click Restrict key and select only the Cloud Text-to-Speech API.
- Application restriction: if the key is used by your web server (a WordPress site, a backend, a cron job), choose IP addresses and add your server's external IP. Internal IPs and localhost are not supported. The Websites (HTTP referrer) option is meant for keys called from a browser, which you should avoid for a paid API. A key can have only one application restriction type at a time.
API key or service account: which one do you need?
Google's Text-to-Speech REST API accepts an API key (its official API discovery document lists the key parameter), and that is the simplest option for a small server-side integration. Google's own Text-to-Speech guides, however, authenticate with OAuth access tokens: gcloud user credentials for testing, a service account attached to the resource when your code runs on Google Cloud, and workload identity federation elsewhere.
Many tools accept a service account key, a JSON file you download from IAM & Admin > Service Accounts, open the account, then Keys > Add key > Create new key > JSON. Google notes that these keys can become a security risk if not managed carefully, so treat the file like a password. Use whatever your tool asks for, and lock it down.
Test your key with a curl request
This request uses the official text:synthesize endpoint and the request body from Google's command-line quickstart. Save it as request.json:
{
"input": {
"text": "Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets."
},
"voice": {
"languageCode": "en-gb",
"name": "en-GB-Standard-A",
"ssmlGender": "FEMALE"
},
"audioConfig": {
"audioEncoding": "MP3"
}
}
Then send it with your key in the x-goog-api-key header, the format Google documents for API keys with REST:
curl -X POST \
-H "X-goog-api-key: API_KEY" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://texttospeech.googleapis.com/v1/text:synthesize"
If you use the gcloud CLI instead of an API key, Google's quickstart sends the same request like this:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: PROJECT_ID" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://texttospeech.googleapis.com/v1/text:synthesize"
A working key returns JSON with an audioContent field. That is your MP3, base64-encoded. Decode it (for example with base64 --decode on macOS or certutil -decode on Windows) and play the file. Google recommends the header over the ?key= query parameter, because a key in a URL can be stolen through URL scans.
Is Google text to speech free?
Partly. Google Cloud Text-to-Speech is priced per character each month, with a free monthly allowance for most voice types. Billing must be enabled, and you are charged automatically once you go over the free characters. Here is the official pricing page (opens in a new tab) as of September 2026:
| Voice type | Free usage per month | Price after the free usage |
|---|---|---|
| Standard | 0 to 4 million characters | US$4 per 1 million characters |
| WaveNet | 0 to 4 million characters | US$4 per 1 million characters |
| Neural2 | 0 to 1 million characters | US$16 per 1 million characters |
| Polyglot (Preview) | 0 to 1 million characters | US$16 per 1 million characters |
| Chirp 3: HD | 0 to 1 million characters | US$30 per 1 million characters |
| Studio | 0 to 1 million characters | US$160 per 1 million characters |
| Instant custom voice | Not available | US$60 per 1 million characters |
| Gemini-TTS models | Not available | Priced per text and audio token |
A few details from the same page are worth knowing. Spaces and newlines count as characters, and so do SSML tags (except <mark>). Google's quotas page also limits each request to 5,000 bytes, so long articles are sent in chunks. New Google Cloud customers can get the Free Trial, currently a $300 credit to spend over 90 days. Prices change, so recheck the pricing page before you budget.
Security best practices for your key
- Never put the key in front-end JavaScript or commit it to a repository. Google's guidance is that the client should send requests to your server, and the server adds the credential. Anyone who can read your page source can spend your money.
- Restrict it to the Cloud Text-to-Speech API and to your server's IP address.
- Delete keys you don't use and rotate active keys periodically.
- Set a budget alert in Billing > Budgets & alerts. Google points out that an alerts-only budget does not cap spending on its own. It emails you so you can act.
Common Google text to speech API errors and fixes
| What you see | What it means | Fix |
|---|---|---|
API key not valid (reason API_KEY_INVALID) | The key string is wrong, incomplete or deleted. | Copy the key again from Credentials, with no extra spaces. |
Method doesn't allow unregistered callers | No key or token reached Google. | Check the header name and that your code actually sends the key. |
SERVICE_DISABLED | The Cloud Text-to-Speech API is not enabled in the key's project. | Enable the API in that same project. |
BILLING_DISABLED | The project has no active billing account. | Link or re-enable billing for the project. |
API_KEY_SERVICE_BLOCKED | The key's API restriction does not include Text-to-Speech. | Add the Cloud Text-to-Speech API to the key's API restrictions. |
API_KEY_IP_ADDRESS_BLOCKED or API_KEY_HTTP_REFERRER_BLOCKED | The request came from an IP or website the key does not allow. | Add your server's external IP, or fix the website list. |
429 / RATE_LIMIT_EXCEEDED | You hit a per-minute request quota. | Slow down and retry, or request a quota increase in the console. |
Using Google Cloud voices on WordPress with AtlasVoice Pro
AtlasVoice Pro is our plugin, so here is exactly how it works. It does not ask for an API key string. The Google Cloud TTS integration takes a service account JSON key file, and the plugin's built-in Setup Guide walks you through it:
- In the Google Cloud console, create or select a project and enable the Cloud Text-to-Speech API (and the Cloud Storage API only if you want MP3 backups in Cloud Storage).
- Go to IAM & Admin > Service Accounts, create a service account, and grant the roles listed in the plugin's Setup Guide. Google advises against granting the broad Owner, Editor or Viewer roles in production.
- Open the service account, go to Keys > Add key > Create new key, choose JSON and download the file. Google only lets you download it once.
- In WordPress, open the AtlasVoice dashboard, go to Integrations, choose Google Cloud TTS, and upload the JSON file. The plugin checks that it really is a service account file.
- Click Test TTS Connection. A short test clip plays if everything works, and the plugin shows hints if the API is disabled, permissions are missing or you hit a quota.
- In the Customization tab, use Select Player to choose Google Cloud TTS, then pick a language and a matching voice under Listening. Google voice names start with their language code, such as
en-GB-Standard-A.
Your server needs the PHP BCMath extension and a writable uploads folder. Google Cloud voices are bring your own key: the Pro licence does not include Google usage, and Google bills your own Cloud account for every character your site converts. Keep this service account in a project used only for text to speech, and set a budget alert. For the wider setup, see our guide to adding text to speech to WordPress posts (opens in a new tab).
Prefer to skip Google Cloud setup?
If billing accounts and service accounts feel like too much, there are simpler routes (all ours, so weigh them as such):
- AtlasVoice API: an HTTP API that turns text into MP3, with a free plan of 100,000 characters a month and keys from app.atlasvoice.cloud (opens in a new tab). See the AtlasVoice API page (opens in a new tab) or the launch announcement (opens in a new tab).
- AtlasVoice Cloud with Pro: natural voices included in the AtlasVoice Pro licence, with no API key or cloud account to manage.
To see how other services compare, read our roundup of free text to speech APIs (opens in a new tab).
Next step
Create your project, enable billing and the API, make a restricted key, and run the curl test above before you paste the key anywhere. If you are on WordPress and want Google voices, set up a service account for AtlasVoice Pro (opens in a new tab) instead, or start with the free AtlasVoice API plan if you'd rather not manage Google Cloud at all.


