Use the OpenAI SDK with KeepRouter

KeepRouter exposes an OpenAI-compatible chat endpoint at https://keeprouter.com/v1. Point the OpenAI SDK's base_url at it and select a chat-capable model from the live catalog. KeepRouter keeps the client-facing OpenAI request shape and routes or translates it to the configured upstream channel. Other modalities use their route-specific SDK methods and endpoints.

Change two things

For supported operations, keep the standard OpenAI request shape and set the KeepRouter base URL, key, and catalog model id:

from openai import OpenAI

client = OpenAI(
    base_url="https://keeprouter.com/v1",   # KeepRouter endpoint
    api_key="sk-kr-your-key",               # KeepRouter key
)

r = client.chat.completions.create(
    model="claude-opus-4-8",                # choose a supported catalog model
    messages=[{"role": "user", "content": "Hello"}],
)

Node / TypeScript is the same idea:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://keeprouter.com/v1", // KeepRouter endpoint
  apiKey: process.env.KEEPROUTER_KEY,   // KeepRouter key
});

const r = await client.chat.completions.create({
  model: "gemini-3.5-flash",            // choose a supported catalog model
  messages: [{ role: "user", content: "Hello" }],
});

One codebase, compatible chat models

Set model to a compatible chat id from the catalog — no provider-specific chat SDK per maker:

ModelMakerPublished price
claude-opus-4-8Anthropic$5.00 per 1M input tokens and $25.00 per 1M output tokens
gpt-4oOpenAI$2.50 per 1M input tokens and $10.00 per 1M output tokens
gemini-3.5-flashGoogle DeepMind$1.50 per 1M input tokens and $9.00 per 1M output tokens
deepseek-v4-proDeepSeek$0.4350 per 1M input tokens and $0.8700 per 1M output tokens
free$0 (free)

See every model and price on Models & pricing.

Frequently asked questions

Do I need to change my code beyond base_url and the key?

For supported chat operations, keep the standard OpenAI SDK request shape, set KeepRouter's base_url and key, and choose a compatible chat model id from the live catalog.

Can I call a Claude model with the OpenAI SDK?

Yes, when that model has an OpenAI-compatible route. KeepRouter translates between the client request and the selected upstream protocol where required.

Does streaming work?

Pass stream=True / stream: true on compatible chat routes; support depends on the selected model and active route.

Do tool calls / function calling work?

On compatible chat routes, supported tool calls are passed through or translated; support depends on the selected model and active route.

Which clients work?

Any OpenAI-compatible client or library — Python, Node, Go, and the many tools that accept an OpenAI base URL.

Get an API key · Models & pricing · This page as Markdown