Gemini SDK
Google’s Gen AI SDK works with the gateway once it is given two things: the gateway’s address as its base URL, and v1beta as its API version. It speaks Google’s own format, which the Gemini models answer.
Install
Section titled “Install”pip install google-genainpm install @google/genaiPoint the client at the gateway
Section titled “Point the client at the gateway”import osfrom google import genaifrom google.genai import types
client = genai.Client( api_key=os.environ["EXOTIC_API_KEY"], http_options=types.HttpOptions( base_url="https://api.exoticrouter.com", api_version="v1beta", ),)
response = client.models.generate_content( model="gemini-4-neon", contents="Say hello in five words.",)print(response.text)import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: process.env.EXOTIC_API_KEY, apiVersion: "v1beta", httpOptions: { baseUrl: "https://api.exoticrouter.com" },});
const response = await ai.models.generateContent({ model: "gemini-4-neon", contents: "Say hello in five words.",});console.log(response.text);- The base URL is the gateway’s address without a path. The SDK adds the API version and the rest.
- The key is sent in
x-goog-api-key, where the gateway reads it.
The models
Section titled “The models”This API serves the Gemini models. Name one the way Google’s API does, by its name alone: gemini-4-neon. The answer’s modelVersion is the model’s full id, google/gemini-4-neon.
For any other model, Claude or GPT or DeepSeek, use the OpenAI SDK: every text model answers Chat Completions, the Gemini models included.
What you can call
Section titled “What you can call”| SDK call | Served |
|---|---|
models.generate_content / models.generateContent |
Yes |
models.generate_content_stream / models.generateContentStream |
Yes |
models.count_tokens / models.countTokens |
Yes, an estimate counted by the gateway, free |
models.embed_content |
No |
models.list |
No; read the gateway’s own list of models |
Files, caches, tunings, live sessions |
No |
The body of a request reaches the model as the SDK builds it: system instructions, tools, thinking and the generation config.
Streaming
Section titled “Streaming”for chunk in client.models.generate_content_stream( model="gemini-4-neon", contents="Write a haiku about glass.",): print(chunk.text, end="", flush=True)const stream = await ai.models.generateContentStream({ model: "gemini-4-neon", contents: "Write a haiku about glass.",});for await (const chunk of stream) { process.stdout.write(chunk.text ?? "");}Tools that read the environment
Section titled “Tools that read the environment”Gemini CLI and other tools built on Google’s SDK take the address and the key from the environment. Gemini CLI has the full setup.
export GOOGLE_GEMINI_BASE_URL="https://api.exoticrouter.com"export GEMINI_API_KEY="sk-er-..."$env:GOOGLE_GEMINI_BASE_URL = "https://api.exoticrouter.com"$env:GEMINI_API_KEY = "sk-er-..."