Use Gemini Interactions through AI Gateway
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/interactionswith 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, soprevious_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 for other Gemini models. With your own Google key, Google bills you directly.
See the Google Gen AI SDK guide and Google provider docs.
Get started
Create an ngrok account or sign in. Create an access key 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:
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:
Set your ngrok access key and run the example:
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:
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 covers the rest of the SDK setup.
Open Logs, find the request you just sent, and inspect its model, provider, status, token usage, and cost.