Skip to content
exoticrouter.com ↗

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.

Python
pip install google-genai
TypeScript
npm install @google/genai
Python
import os
from google import genai
from 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)
TypeScript
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.

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.

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.

Python
for chunk in client.models.generate_content_stream(
model="gemini-4-neon",
contents="Write a haiku about glass.",
):
print(chunk.text, end="", flush=True)
TypeScript
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 ?? "");
}

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.

Shell
export GOOGLE_GEMINI_BASE_URL="https://api.exoticrouter.com"
export GEMINI_API_KEY="sk-er-..."
PowerShell
$env:GOOGLE_GEMINI_BASE_URL = "https://api.exoticrouter.com"
$env:GEMINI_API_KEY = "sk-er-..."
  • Gemini: The endpoints this SDK calls.
  • Errors: How errors are shaped on this API.