Official SDKs for the most popular languages. REST API for everything else.
Five official clients, all OpenAI-compatible, all auto-routing.
Sync and async clients. Full type hints. Tested against CPython 3.9 โ 3.13.
from greatrouter import GreatRouter
client = GreatRouter(api_key="...")
resp = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Hi"}]
) ESM and CJS. Tree-shakeable. Works in Node, Bun, Deno, and the browser.
import GreatRouter from "greatrouter";
const gr = new GreatRouter({ apiKey: process.env.ROUTER_KEY });
const r = await gr.chat.completions.create({
model: "auto",
messages: [{ role: "user", content: "Hi" }],
}); Idiomatic Go client. Context-aware. Used in our own routing layer.
import "github.com/greatrouter/greatrouter-go"
client := greatrouter.NewClient("...")
resp, _ := client.Chat.Completions.Create(ctx, &gr.ChatRequest{
Model: "auto",
Messages: []gr.Message{{Role: "user", Content: "Hi"}},
}) Sane defaults. Works with Rails, Sinatra, and plain Ruby scripts.
require "greatrouter"
client = GreatRouter::Client.new(api_key: ENV["ROUTER_KEY"])
resp = client.chat.completions.create(
model: "auto",
messages: [{ role: "user", content: "Hi" }],
) OpenAI-compatible REST endpoints. Use any HTTP client, in any language.
POST https://api.greatrouterai.com/v1/chat/completions
Authorization: Bearer <api-key>
Content-Type: application/json
{
"model": "auto",
"messages": [{ "role": "user", "content": "Hi" }]
} A complete TypeScript example using the official client. Streaming, function calling, and error handling included.
import GreatRouter from "greatrouter";
const client = new GreatRouter({ apiKey: process.env.ROUTER_KEY });
async function main() {
const stream = await client.chat.completions.create({
model: "auto",
stream: true,
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Stream me a haiku about AI." },
],
});
for await (const chunk of stream) {
const delta = chunk.choices[0]?.delta?.content ?? "";
process.stdout.write(delta);
}
}
main().catch((err) => {
console.error(err);
process.exit(1);
}); The same pattern in Python โ sync or async, with a familiar OpenAI-style API.
import asyncio
from greatrouter import GreatRouter, AsyncGreatRouter
client = AsyncGreatRouter(api_key="...")
async def main():
stream = await client.chat.completions.create(
model="auto",
stream=True,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Stream me a haiku about AI."},
],
)
async for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)
asyncio.run(main()) Apache 2.0. Contributions welcome. Open issues, send PRs, or write a binding for your favorite language โ we'll list it here.