# Use Gemini Interactions through AI Gateway

> Send Gemini Interactions API requests through AI Gateway with Google's Gen AI SDK for Python or TypeScript.

- Date: 2026-10-15
- Shipped by: Nijiko Yonskai
- Products: AI Gateway
- URL: https://ngrok.com/changelog/ai-gateway-gemini-interactions-api

ngrok AI Gateway now supports Gemini's Interactions API, alongside GenerateContent and streaming.

Use Google's Gen AI SDK for Python or TypeScript, point it at `https://gateway.ngrok.ai`, and authenticate with your ngrok access key.

- Send Interactions to `/v1beta/interactions` with JSON or SSE responses.
- Run on ngrok-managed inference with your credits, or bring your own Google key.
- Interactions are stateless. The gateway uses `store=false`, so `previous_interaction_id`, background execution, retrieval, and agents aren't supported.
- Managed Interactions supports text input and text or JSON output on the Standard tier.

Managed requests bill to your ngrok credits at the model's token rates. `gemini-3.6-flash`, the model in the example below, costs $0.75 per million input tokens and $3.75 per million output tokens. Check [**Models**](https://app.ngrok.ai/models) for other Gemini models. With your own Google key, Google bills you directly.

See the [Google Gen AI SDK guide](https://ngrok.com/docs/ai-gateway/sdks/google) and [Google provider docs](https://ngrok.com/docs/ai-gateway/providers/google).

## Get started

[Create an ngrok account or sign in](https://app.ngrok.ai/). Create an [**access key**](https://app.ngrok.ai/keys) that allows Google, and confirm your account has credits. To use your own Google key instead, attach it to the gateway.

Install Google's Gen AI SDK for Python:

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

This example asks Gemini whether a production alert needs someone awake right now. `response_format` makes the model reply with JSON that matches a schema, so your code reads a field instead of parsing prose.

Point the client at AI Gateway and pass your ngrok access key through the SDK's normal `api_key` setting. Save this example as `main.py`:

```python
import json
import os

from google import genai
from google.genai import types

client = genai.Client(
    api_key=os.environ["NGROK_AI_GATEWAY_KEY"],
    http_options=types.HttpOptions(
        base_url="https://gateway.ngrok.ai",
        api_version="v1beta",
    ),
)

alert = "checkout-api: 5xx rate at 38% for 6 minutes. p99 latency 4.2s. Last deploy 9 minutes ago."

interaction = client.interactions.create(
    model="gemini-3.6-flash",
    input=f"Is this production alert urgent enough to page the on-call engineer?\n\n{alert}",
    response_format={
        "type": "text",
        "mime_type": "application/json",
        "schema": {
            "type": "object",
            "properties": {
                "urgent": {"type": "boolean"},
                "reason": {"type": "string"},
            },
            "required": ["urgent", "reason"],
        },
    },
    store=False,
)

triage = json.loads(interaction.output_text)
print("Page on-call" if triage["urgent"] else "Wait for business hours")
print(triage["reason"])
```

Set your ngrok access key and run the example:

```bash
export NGROK_AI_GATEWAY_KEY=your_access_key_here
python main.py
```

`interaction.output_text` holds the model's JSON as a string. The example parses it and branches on `urgent`. The output looks something like this, though the reason varies between runs:

```text
Page on-call
Checkout is failing for over a third of requests, and the errors started right after a deploy.
```

For a free-form answer, drop `response_format` and print `interaction.output_text` directly. The request keeps Google's native Interactions format. The [Google Gen AI SDK guide](https://ngrok.com/docs/ai-gateway/sdks/google) covers the rest of the SDK setup.

Open [**Logs**](https://app.ngrok.ai/activity), find the request you just sent, and inspect its model, provider, status, token usage, and cost.
