Gateway
Gemini-compatible API
Native Google Gemini /v1beta surface — generateContent, streamGenerateContent and the google-genai SDK.
ToRouter mounts a native Gemini surface at /v1beta. The official google-genai SDK and the Gemini CLI work without modification.
Endpoints
| Method | Path | Purpose |
|---|---|---|
GET | /v1beta/models | List available models |
GET | /v1beta/models/{model} | Model metadata |
POST | /v1beta/models/{model}:generateContent | One-shot generation |
POST | /v1beta/models/{model}:streamGenerateContent | SSE streaming |
POST | /v1beta/models/{model}:countTokens | Count tokens |
Both /v1beta/* and /api/v1beta/* are accepted.
Auth
Either form works:
?key=sk-***or as a header:
x-goog-api-key: sk-***Python SDK (google-genai)
from google import genai
client = genai.Client(
api_key="sk-***",
http_options={"base_url": "https://portal.torouter.ai/v1beta"},
)
resp = client.models.generate_content(
model="gemini-3-flash-preview",
contents="Why is the sky blue?",
)
print(resp.text)curl
curl "https://portal.torouter.ai/v1beta/models/gemini-3-flash-preview:generateContent?key=sk-***" \
-H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"hi"}]}]}'Streaming:
curl "https://portal.torouter.ai/v1beta/models/gemini-3-flash-preview:streamGenerateContent?alt=sse&key=sk-***" \
-H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"count to 5"}]}]}'The Gemini surface forwards generationConfig, safetySettings, tools and systemInstruction unmodified.