OpenAI SDK base URL for KeepRouter: Python, Node, and Go

Use https://keeprouter.com/v1 as the OpenAI SDK base URL. In Python the option is base_url; in Node it is baseURL; in the official Go SDK it is option.WithBaseURL. All three SDKs can also read OPENAI_BASE_URL. Replace the API key and select an exact chat-compatible model from the live KeepRouter catalog.

Before changing configuration, use the local API migration checker to review credential-free JSON, exact model IDs and unsupported routing assumptions. Download the Python and Node starter pack for controlled tests in your own environment.

Copy the exact value

ClientSettingKeepRouter value
Pythonbase_url or OPENAI_BASE_URLhttps://keeprouter.com/v1
Node / TypeScriptbaseURL or OPENAI_BASE_URLhttps://keeprouter.com/v1
Gooption.WithBaseURL or OPENAI_BASE_URLhttps://keeprouter.com/v1

The SDK appends /chat/completions. Do not pass the complete operation URL as the base URL and do not remove /v1.

Python

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-fable-5-1",               # choose a supported catalog model
    messages=[{"role": "user", "content": "Hello"}],
)

Environment-only configuration:

export OPENAI_BASE_URL=https://keeprouter.com/v1
export OPENAI_API_KEY=sk-kr-your-key

Node and TypeScript

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.8-flash",            // choose a supported catalog model
  messages: [{ role: "user", content: "Hello" }],
});

Keep paid API keys server-side. A browser bundle can expose the credential.

Go

client := openai.NewClient(
    option.WithBaseURL("https://keeprouter.com/v1"),
    option.WithAPIKey(os.Getenv("KEEPROUTER_KEY")),
)

One codebase, compatible chat models

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

ModelMakerPublished price
deepseek-flashDeepSeek$0.3000 per 1M input tokens and $1.20 per 1M output tokens
gpt-6-astraOpenAI$25.00 per 1M input tokens and $75.00 per 1M output tokens
claude-fable-5-1Anthropic$20.00 per 1M input tokens and $50.00 per 1M output tokens
gemini-3.8-flashGoogle DeepMind$0.7500 per 1M input tokens and $3.75 per 1M output tokens
qwen3.8-max-0902Alibaba$2.50 per 1M input tokens and $6.00 per 1M output tokens
free—$0 (free)

See every model and price on Models & pricing.

Chat Completions is not every OpenAI route

OperationCan use the same base URL?What to verify
Chat CompletionsYes, for a chat-compatible modelModel page lists the chat endpoint
ResponsesThe SDK method can target the same baseThe selected model has a configured Responses route and the application handles its request and event contract
Embeddings, images, audioOnly when the model page and OpenAPI publish the operationModality-specific request, output, and billing unit
Anthropic MessagesNo OpenAI SDK methodUse the Anthropic-compatible client surface

The public OpenAPI document is the route-level contract.

Base URL migration map

ServiceOpenAI SDK base URLModel namespace
OpenAIhttps://api.openai.com/v1OpenAI IDs
OpenRouterhttps://openrouter.ai/api/v1OpenRouter slugs
KeepRouterhttps://keeprouter.com/v1KeepRouter catalog IDs

Changing URL and key does not translate model IDs or product-specific routing fields. See the OpenRouter Python SDK guide for the native and OpenAI SDK paths.

Troubleshooting

SymptomCheck first
401Key exists in the running process, has no extra whitespace, is not revoked, and reaches the KeepRouter host
404Base URL includes exactly one /v1 and application code did not append /chat/completions
Model not foundUse an exact current KeepRouter ID; OpenAI and OpenRouter IDs do not transfer
Endpoint not supportedThe model page lists the operation the SDK method calls
Streaming stopsSelected route support, SSE parsing, cancellation, and bounded retries
Tool continuation failsComplete tool result, required prior messages, and the exact model
Browser exposes a keyMove the call to a server-side route

Production verification

Start with a deterministic non-streaming prompt. Record returned model, request ID, token usage, HTTP status, and billed amount. Then test streaming, cancellation, one real tool round trip, and a bounded error.

Frequently asked questions

What is the KeepRouter OpenAI SDK base URL?

Use https://keeprouter.com/v1 exactly.

Is Python base_url the same as Node baseURL?

They configure the same concept, but the option spelling follows each SDK.

Can I use OPENAI_BASE_URL instead?

Yes. Current official Python, Node, and Go SDKs read it when an explicit constructor option is not supplied.

Can I copy an OpenRouter model slug?

No. Use an exact model ID from the live KeepRouter catalog; catalog namespaces are not shared.

Does the base URL enable Responses automatically?

No. The selected model needs a configured Responses route, and the application must use the Responses request and event contract.

How do I get a key?

Create a scoped KeepRouter key, then verify the exact model endpoint before calling it.

Sources reviewed 2026-09-11

Get a scoped API key · Models & pricing · Error reference · This page as Markdown