# 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="/files/g7WBalur1jMIDYv3tzPb" 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="/files/7rce4x1KHnOExZHAAfwT" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mydbsync.com/cloud-workflow/create-your-workflow/actions/ai-agent-api-key-guides/gemini-api-key.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
