Skip to main content
Version: next

Any OpenAI SDK app

Anything built on the official OpenAI SDKs, or on any library that reads OPENAI_BASE_URL, works with Routerly by changing the base URL and the API key. No client-side code changes: Routerly forwards the request and returns the provider's response unaltered.

Support state: documented. Configured by hand. Config: environment variables, no file Wire format: OpenAI Connect modes: LLM


routerly clients configure generic-openai --router my-api

Prints the two variables with a real router token, mints one if you do not pass --token, and writes nothing. The dashboard shows the same pair under Connect → Any OpenAI SDK app.

Environment variables​

export OPENAI_BASE_URL=http://localhost:3000/v1
export OPENAI_API_KEY=sk-rt-YOUR_ROUTER_TOKEN

The /v1 suffix belongs to the base URL. Create a router token on the Routers page.

In code​

from openai import OpenAI

client = OpenAI(
base_url="http://localhost:3000/v1",
api_key="sk-rt-YOUR_ROUTER_TOKEN",
)

response = client.chat.completions.create(
model="routerly/ada",
messages=[{"role": "user", "content": "Hello"}],
)
import OpenAI from 'openai';

const client = new OpenAI({
baseURL: 'http://localhost:3000/v1',
apiKey: 'sk-rt-YOUR_ROUTER_TOKEN',
});

const response = await client.chat.completions.create({
model: 'routerly/ada',
messages: [{ role: 'user', content: 'Hello' }],
});

routerly/ada asks Routerly to pick the model per request, following the router's routing profile. Pass a registered model id instead to address one model directly.

Check the connection​

routerly clients doctor

Reports whether the service is reachable from this machine. See Examples for one runnable snippet per language, and Concepts: Routing for how a request is routed.