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

OpenAI-compatible API

Use the OpenAI SDK with ToRouter for chat completions, responses, embeddings and image generation.

ToRouter speaks native OpenAI on every endpoint your SDK uses. Change base_url and the key — your code is otherwise untouched.

Endpoints

MethodPathPurpose
POST/v1/chat/completionsChat (OpenAI / Anthropic / Gemini / OpenRouter upstreams)
POST/v1/responsesResponses API (reasoning, tool use, multi-turn state)
POST/v1/embeddingsText embeddings
POST/v1/images/generationsText → image
POST/v1/images/editsImage editing (multipart)
GET/v1/modelsList available models

Tool/function calling, JSON mode, response_format, tool_choice and structured outputs are passed through unchanged.

Python SDK

example.py
from openai import OpenAI

client = OpenAI(
    api_key="sk-***",
    base_url="https://portal.torouter.ai/v1",
)

resp = client.chat.completions.create(
    model="gpt-5",
    messages=[{"role": "user", "content": "Write a haiku about routers."}],
)
print(resp.choices[0].message.content)

The same client works for client.embeddings.create(...), client.images.generate(...) and client.responses.create(...).

curl

curl https://portal.torouter.ai/v1/embeddings \
  -H "Authorization: Bearer sk-***" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/text-embedding-3-small","input":"hello world"}'

Embeddings require an API key on an OpenAI or OpenRouter group. Use the full model id from the model catalog (e.g. openai/text-embedding-3-small on OpenRouter). The gateway also accepts /api/v1/embeddings.

The OpenAI compat layer also fronts Anthropic and Gemini upstreams — if your group is on a Claude or Gemini account, gpt-5 style models get auto-translated. See Model identifiers.

Next steps

Streaming responses

Enable stream: true.

Python integration

Full SDK walkthrough.

Node.js integration

Same, in TypeScript.

Base URL & authentication

Endpoint table for the ToRouter gateway — OpenAI, Anthropic and Gemini protocols, with both /v1 and /api/v1 mount points.

Anthropic-compatible API

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

Table of Contents

EndpointsPython SDKcurlNext steps