> For the complete documentation index, see [llms.txt](https://docs.haikaldev.my.id/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.haikaldev.my.id/koneksi-ai/google-ai-studio.md).

# Google AI Studio

Gemini adalah **telinga** AI-Haikaru — dan pemberi reaksi emoji. Perannya sempit, tapi tidak ada penggantinya: gateway utama tidak punya jalur audio sama sekali (lihat [OhhMyAgent](/koneksi-ai/ohhmyagent.md)).

{% hint style="danger" %}
**Tanpa key Gemini, bot tuli.** Voice note tidak terbaca, tidak masuk arsip, dan pencarian audio selamanya kosong — walau semua fitur lain berjalan normal.
{% endhint %}

## Yang dikerjakan Gemini

| Fitur                          | Detail                                                                                                                                       |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| 🎙️ **Transkripsi voice note** | VN → teks, masuk ke konteks percakapan sehingga bot bisa membalas isinya                                                                     |
| 🗄️ **Arsip audio**            | Tiap VN disimpan + transkrip + 6 pesan sebelum & sesudah sebagai konteks. Bisa dicari: *"ada audio si Roihan bilang 'aku mau jeruk' nggak?"* |
| 😀 **Auto-reaction**           | Emoji reaksi otomatis di pesan tertentu — pekerjaan receh yang justru butuh model murah dan cepat                                            |

Model yang dipakai: `gemini-3.1-flash-lite`. Tier gratisnya cukup untuk pemakaian grup normal.

## Bikin API key (gratis)

{% stepper %}
{% step %}

### Buka AI Studio

[aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey)
{% endstep %}

{% step %}

### Create API key

Login akun Google → **Create API key** → salin key-nya (berformat `AIzaSy...`).
{% endstep %}

{% step %}

### Masukkan ke `.env`

```env
GEMINI_API_KEYS=AIzaSy-key-kamu
GEMINI_MODEL=gemini-3.1-flash-lite
```

{% endstep %}
{% endstepper %}

## Multi-key & rotasi otomatis

Tier gratis punya limit harian **per key**. Bot mendukung beberapa key sekaligus, dipisah koma:

```env
GEMINI_API_KEYS=AIzaSy-key1,AIzaSy-key2,AIzaSy-key3
```

Perilaku rotasinya (terpusat di `handlers/geminiClient.js`):

* Key kena limit/429 → **otomatis pindah** ke key berikutnya
* Key error permanen → **di-skip**, fitur tetap jalan dengan sisanya
* Semua key habis → fitur audio menolak **dengan pesan jelas**, bot tetap hidup

{% hint style="success" %}
**Tips:** bikin 2–3 key dari akun Google berbeda kalau grupmu rajin kirim VN. Limitnya per key, bukan per proyek.
{% endhint %}

## Kalau dibiarkan kosong

Sengaja didesain **gagal dengan suara**, bukan diam-diam:

| Kapan      | Yang terjadi                                                                    |
| ---------- | ------------------------------------------------------------------------------- |
| Saat start | Log memperingatkan `GEMINI_API_KEYS kosong` + menyebut fitur apa saja yang mati |
| VN masuk   | Bot menjawab bahwa dia tidak bisa mendengar — **bukan pura-pura sudah dengar**  |
| Fitur lain | Auto-reaction mati; sisanya tidak tersentuh                                     |

## Privasi

{% hint style="info" %}
Audio dikirim ke Google **hanya untuk ditranskripsi**, saat VN masuk. Arsip audio dan transkripnya disimpan **lokal** di `data/audio_archive/`.

Pencariannya dibatasi per chat: audio dari grup A tidak pernah muncul dalam pencarian di grup B — pembatasan yang ditegakkan di kode, bukan sekadar diminta ke model.
{% endhint %}

Model keamanan lengkapnya di [Keamanan](/referensi/keamanan.md).

## Terkait

* Peta koneksi AI: [Peta koneksi](/koneksi-ai/koneksi-ai.md)
* Gateway utama: [OhhMyAgent](/koneksi-ai/ohhmyagent.md)
* *"Bot bilang tidak bisa dengar"* dan gejala sejenis: [Troubleshooting](/referensi/troubleshooting.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.haikaldev.my.id/koneksi-ai/google-ai-studio.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
