Gemini
Google’s generateContent format, for the Gemini models. The model is named in the URL, the key goes where Google’s clients put it, and the body is passed to the model exactly as you send it.
POST https://api.exoticrouter.com/v1beta/models/{model}:generateContent
POST https://api.exoticrouter.com/v1beta/models/{model}:streamGenerateContent
A request
Section titled “A request”curl "https://api.exoticrouter.com/v1beta/models/google/gemini-4-neon:generateContent" \ -H "x-goog-api-key: $EXOTIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{"parts": [{"text": "Why is the sky blue?"}]}] }'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="Why is the sky blue?",)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: "Why is the sky blue?",});console.log(response.text);The model, the key and the body
Section titled “The model, the key and the body”- The model is the part of the URL between
models/and the colon. It may be the full id, written with its slash as ingoogle/gemini-4-neon, or the name alone,gemini-4-neon. Amodelfield in the body is not read. - It has to be a model that answers on this endpoint: the Gemini models. For any other model use Chat Completions.
- The key is read from
x-goog-api-key, which Google’s SDKs send, or from?key=in the URL. - The body goes to the model exactly as sent:
contents,systemInstruction,tools,generationConfigand the rest.
The answer
Section titled “The answer”{ "candidates": [ { "content": { "role": "model", "parts": [{ "text": "Sunlight is scattered by the air, and blue light is scattered the most." }] }, "finishReason": "STOP" } ], "usageMetadata": { "promptTokenCount": 7, "candidatesTokenCount": 16, "totalTokenCount": 23 }, "modelVersion": "google/gemini-4-neon"}It is Google’s own response. modelVersion is the model’s full id. usageMetadata is the model’s own report; the input figure you are billed on is the gateway’s own count and can differ from it. Thinking tokens are billed as output.
Streaming
Section titled “Streaming”Call :streamGenerateContent for the answer as it is written. Add ?alt=sse to get server-sent events, one response chunk to a data: line. Without it the answer is one JSON array that arrives piece by piece.
curl -N "https://api.exoticrouter.com/v1beta/models/google/gemini-4-neon:streamGenerateContent?alt=sse" \ -H "x-goog-api-key: $EXOTIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{"parts": [{"text": "Write a haiku about glass."}]}] }'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 ?? "");}Prefer alt=sse. If the model fails after the stream has begun, an SSE stream ends with one error event; a JSON array simply stops early, and the only sign is that it does not close.
Errors
Section titled “Errors”Errors are shaped the way Google shapes them:
{ "error": { "code": 429, "message": "Rate limit exceeded for this API key. Please slow down.", "status": "RESOURCE_EXHAUSTED" }}status follows the HTTP status: UNAUTHENTICATED for 401, FAILED_PRECONDITION for 402, NOT_FOUND for 404, RESOURCE_EXHAUSTED for 429, UNAVAILABLE for 503. Errors lists them all.
Where next
Section titled “Where next”- Gemini SDK: Google’s Gen AI client, pointed at the gateway.
- Gemini CLI: The agent that speaks this format.