LogoToRouter Docs
LogoToRouter Docs
HomepageWhat is ToRouter5-minute quickstartCore concepts
Base URL & authenticationOpenAI-compatible APIAnthropic-compatible APIGemini-compatible APIStreaming responses (SSE)Model identifiers & vendor prefixesPlayground — test in the browser
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

MethodPathPurpose
GET/v1beta/modelsList available models
GET/v1beta/models/{model}Model metadata
POST/v1beta/models/{model}:generateContentOne-shot generation
POST/v1beta/models/{model}:streamGenerateContentSSE streaming
POST/v1beta/models/{model}:countTokensCount 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)

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

Next steps

Streaming responses

SSE event format details.

Gemini SDK integration

Full walkthrough for google-genai.

Model identifiers

Gemini model naming.

Anthropic-compatible API

Use the native Anthropic SDK against ToRouter — /v1/messages, count_tokens, prompt caching and anthropic-beta headers all pass through.

Streaming responses (SSE)

Stream tokens incrementally over Server-Sent Events for OpenAI, Anthropic and Gemini protocols.

Table of Contents

EndpointsAuthPython SDK (google-genai)curlNext steps