# Gemini API Key

Google's Gemini models are accessible through Google AI Studio for development and prototyping. For production workloads, Google recommends migrating to Vertex AI on Google Cloud. A generous free tier makes Gemini an easy starting point.

### Prerequisites

You need the following:

* A Google account
* Gemini API availability in your region (check during setup)

### Step-by-step instructions

Follow the steps to set up the Gemini API key:&#x20;

{% stepper %}
{% step %}
Go to [aistudio.google.com](https://aistudio.google.com/), click **Get started**, and then sign in with your Google account.
{% endstep %}

{% step %}
On the **Welcome to AI Studio** page, select the **I acknowledge that I am a developer...** checkbox, and then click **Continue**.
{% endstep %}

{% step %}
Click **Get API Key** on the navigation menu, and then click **Create API Key**.
{% endstep %}

{% step %}
In the **Create a new key** dialog, enter a name in the **Name your key** field, select a project in the **Choose an imported project** list, and then click **Create key**. You can either create the API key in Google Cloud project (recommended for beginners), select an existing project, or create a new project.&#x20;
{% endstep %}

{% step %}
**Click** <img src="broken-reference" alt="" data-size="line"> and copy your API ke&#x79;**.** Unlike OpenAI and Anthropic, Google AI Studio lets you view the key again later, but it is still best practice to store it immediately.
{% endstep %}

{% step %}
*Optional:* Click **Set up billing.** In the **Set up your Google Cloud Billing** **account** dialog, select your country in the **Select a country** list, and then click **Agree & continue**.

In **Add your billing account details** dialog, verify your contact information and selected payment method, then click **Submit** to finalize your setup.

{% hint style="info" %}
For new Google Cloud users, an express mode setup provides a free 90-day trial environment with an API key created automatically.
{% endhint %}
{% endstep %}
{% endstepper %}

### Test Your Key

Store your key as the environment variable `GEMINI_API_KEY`. Use the Google Gen AI SDK for Python, TypeScript, or Java. You can also test via `curl` using either the `x-goog-api-key` header or a query parameter.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FAyv0XBlQH7tCPoFK8Tmb%2Fimage.png?alt=media&#x26;token=60c3d65d-5379-4c83-8ef9-d88f8774ae57" alt=""><figcaption></figcaption></figure>
