Getting a Google Translate API key requires a Google Cloud Platform (GCP) account, a billing-enabled project, and a series of configuration steps. It's not hard, but it's more involved than most developers expect. The whole process takes 10-15 minutes if everything goes smoothly.
This guide walks through every step with the exact screens and options you'll encounter.
Prerequisites
- A Google account (personal Gmail works, Google Workspace also works)
- A credit card or debit card for billing setup (required even for the free tier)
- About 15 minutes
Step 1: Create a Google Cloud project
Go to console.cloud.google.com. If this is your first time, Google will ask you to accept terms of service and set your country.
Click the project selector dropdown in the top navigation bar, then click "New Project."
- Project name: Pick something descriptive. "my-app-translation" works. You can't rename it later.
- Organization: If you're using a personal account, this is "No organization." If you're on Google Workspace, select your organization.
- Location: Leave as default unless your organization has specific folder structures.
Click "Create" and wait 10-30 seconds for the project to provision.
Step 2: Enable billing
Google requires billing enabled on the project even if you're only using the free tier. Without billing, API calls return a 403 error.
Go to Billing in the left sidebar (or navigate to console.cloud.google.com/billing).
- If you don't have a billing account: click "Create account," enter your credit card details
- If you have an existing billing account: link your new project to it
New accounts get $300 in free credits valid for 90 days. The Cloud Translation API also has a permanent free tier of 500,000 characters per month. You won't be charged unless you exceed the free tier after the credit period ends.
Step 3: Enable the Cloud Translation API
Navigate to APIs & Services > Library (or search for "Cloud Translation API" in the top search bar).
Find "Cloud Translation API" in the results. There are two versions:
- Cloud Translation API (v2): The simpler version. Standard neural machine translation, straightforward authentication, no model training options. This is what most integrations use.
- Cloud Translation API (v3): Advanced version with glossary support, batch translation, model training, and document translation. Same base pricing but more features. Requires more setup.
For most use cases, v2 is sufficient. Click on the API, then click "Enable." This takes a few seconds.
Step 4: Create an API key
Go to APIs & Services > Credentials.
Click "Create Credentials" at the top, then select "API key."
Google generates a key immediately. It looks like: AIzaSyD-EXAMPLE-NOT-REAL-KEY-12345
Copy this key and store it securely. You'll use this in your API calls.
Restricting your API key (important)
By default, the key works for any Google API from any IP address. That's a security risk. If someone gets your key, they can make API calls on your billing account.
Click "Edit API key" (or click the key name in the credentials list) and add restrictions:
Application restrictions (pick one):
- HTTP referrers: If calling from a web app, restrict to your domain
- IP addresses: If calling from a server, restrict to your server's IP
- None: Only if you're testing locally (change this before production)
API restrictions:
- Select "Restrict key" and choose "Cloud Translation API" from the dropdown
- This prevents the key from being used with other Google APIs
Click "Save."
Step 5: Test your API key
Run a quick test to confirm everything works. Using curl:
curl -X POST \
"https://translation.googleapis.com/language/translate/v2" \
-H "Content-Type: application/json" \
-d '{
"q": "Hello, world",
"target": "es",
"key": "YOUR_API_KEY"
}'
Expected response:
{
"data": {
"translations": [
{
"translatedText": "Hola Mundo",
"detectedSourceLanguage": "en"
}
]
}
}
If you get a 403 error, billing isn't enabled. If you get a 400 error, the API isn't enabled on your project. If you get a 401 error, the API key is invalid.
Step 6: Set quotas and alerts
Don't skip this. Without quotas, a bug in your code or a traffic spike can generate a massive bill overnight.
Go to APIs & Services > Quotas & System Limits.
Find "Cloud Translation API" and set a daily character limit. Reasonable defaults:
- Development: 100,000 characters per day
- Production (small): 1,000,000 characters per day
- Production (medium): 10,000,000 characters per day
Also set up a billing alert. Go to Billing > Budgets & Alerts. Create a budget with email notifications at 50%, 80%, and 100% of your expected monthly spend.
Common mistakes
"API key not valid" error
Usually means you copied the key incorrectly (trailing whitespace or newline), or the key was created in a different project than the one with the Translation API enabled. Check which project the key belongs to.
"Billing account not found" or 403 Forbidden
The project doesn't have billing linked. Go to Billing, confirm the project is associated with a billing account, and that the billing account has a valid payment method.
"Cloud Translation API has not been used" error
You enabled the wrong API, or the API takes a few minutes to propagate. Wait 2-3 minutes and try again. Also double-check you enabled the Translation API, not the similar-sounding "Cloud Natural Language API" or "Cloud Text-to-Speech API."
API key restrictions blocking requests
If you restricted your key to specific IPs or referrers, make sure your actual request comes from an allowed source. For local development, temporarily remove restrictions, get things working, then add them back.
Unexpected billing
The free tier is 500,000 characters per month. If you send 600,000 characters, you pay for the extra 100,000 at $20 per million characters ($2.00). The issue is that character counting includes spaces, punctuation, and HTML tags. A "500-word" document might be 3,000 characters. Set quotas as described in Step 6.
Using the API key in your code
Once you have a working key, integrate it into your application. See our guides for specific languages:
The key goes in the key parameter on each API request or in the x-goog-api-key header. Never hardcode the key in client-side JavaScript. Always call the translation API from your backend.
An easier alternative
The GCP setup process works, but it's more steps than most translation needs require. If you want a simpler path:
Langbly uses the same Google Translate v2 API format. Sign up at langbly.com/signup, get an API key in your dashboard in under 30 seconds, and start translating. No GCP project, no billing setup, no quota configuration.
Since Langbly is v2-compatible, you can use the same client libraries and code examples. Change the base URL from translation.googleapis.com to api.langbly.com, swap the API key, and your existing code works.
The pricing difference is significant too. Google charges $20 per million characters. Langbly starts at $3.80 per million on the Starter plan and goes down to $1.99 per million on the Scale plan. For a detailed comparison, check the Google Translate vs Langbly comparison page.