Skip to content
exoticrouter.com ↗

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

cURL
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?"}]}]
}'
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="Why is the sky blue?",
)
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: "Why is the sky blue?",
});
console.log(response.text);
  • The model is the part of the URL between models/ and the colon. It may be the full id, written with its slash as in google/gemini-4-neon, or the name alone, gemini-4-neon. A model field 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, generationConfig and the rest.
{
"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.

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
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."}]}]
}'
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 ?? "");
}

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 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.

  • Gemini SDK: Google’s Gen AI client, pointed at the gateway.
  • Gemini CLI: The agent that speaks this format.