# Your First Gemini API Request

> Get a Gemini API key from AI Studio, set GEMINI_API_KEY, install the google-genai SDK, and make a working request with the Interactions API. Copy-paste.

- Canonical: https://guides-ai.pages.dev/guides/gemini-api-first-request/
- Plate 15.15 · Topic: Building with the API (https://guides-ai.pages.dev/topics/api/)
- Published: 06 Sept 2026 · 2 min read
- Source site: guides-ai — https://guides-ai.pages.dev/

Google's Gemini API is the third big one after Claude and OpenAI. The current SDKs are `google-genai` (Python) and `@google/genai` (JavaScript); the quickstart uses the **Interactions API**, which takes an `input` and gives you `output_text` back.

## 1. Key

Create a key on the [AI Studio API keys page](https://aistudio.google.com/api-keys), then put it in the environment the SDK reads by default:

```bash
export GEMINI_API_KEY="AIza..."        # macOS/Linux
```

```powershell
$env:GEMINI_API_KEY = "AIza..."         # Windows PowerShell, current session
```

Never paste the key into code you commit — the client picks it up from `GEMINI_API_KEY` on its own.

## 2. Python

```bash
pip install -U google-genai
```

Installs the current SDK (the older `google-generativeai` package is a different, legacy library).

```python
from google import genai

client = genai.Client()  # reads GEMINI_API_KEY

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input="Explain how AI works in a few words",
)
print(interaction.output_text)
```

`gemini-3.8-flash` is the model the quickstart uses today; `output_text` is the assembled reply. If you need the structured form, the response's steps carry content blocks with `text` fields.

## 3. JavaScript

```bash
npm install @google/genai
```

Node 18+; the client reads `GEMINI_API_KEY` from `process.env`.

## 4. curl

```bash
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gemini-3.8-flash", "input": "Explain how AI works in a few words"}'
```

The key travels in the `x-goog-api-key` header (not `Authorization: Bearer`). The text comes back inside `steps[].content[].text`.

## What differs from Claude and OpenAI

- **Header:** `x-goog-api-key` (Gemini) vs `x-api-key` + `anthropic-version` (Claude) vs `Authorization: Bearer` (OpenAI).
- **Shape:** one `input` string in, `output_text` out — closer to OpenAI's Responses API than to Claude's `messages` array.
- **Image generation** has its own model family (`gemini-3.1-flash-image` in the current docs); text models don't draw.

Rate limits and free-tier quotas depend on your AI Studio project — check the limits page there before you put this in a loop.

---

Next: [your first Claude API request](/guides/claude-api-first-request/) · [your first OpenAI API request](/guides/openai-api-first-request/) · [OpenAI API vs Claude API](/guides/openai-vs-claude-api/).
