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
| Client | Setting | KeepRouter value |
|---|---|---|
| Python | base_url or OPENAI_BASE_URL | https://keeprouter.com/v1 |
| Node / TypeScript | baseURL or OPENAI_BASE_URL | https://keeprouter.com/v1 |
| Go | option.WithBaseURL or OPENAI_BASE_URL | https://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-keyNode 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:
| Model | Maker | Published price |
|---|---|---|
deepseek-flash | DeepSeek | $0.3000 per 1M input tokens and $1.20 per 1M output tokens |
gpt-6-astra | OpenAI | $25.00 per 1M input tokens and $75.00 per 1M output tokens |
claude-fable-5-1 | Anthropic | $20.00 per 1M input tokens and $50.00 per 1M output tokens |
gemini-3.8-flash | Google DeepMind | $0.7500 per 1M input tokens and $3.75 per 1M output tokens |
qwen3.8-max-0902 | Alibaba | $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
| Operation | Can use the same base URL? | What to verify |
|---|---|---|
| Chat Completions | Yes, for a chat-compatible model | Model page lists the chat endpoint |
| Responses | The SDK method can target the same base | The selected model has a configured Responses route and the application handles its request and event contract |
| Embeddings, images, audio | Only when the model page and OpenAPI publish the operation | Modality-specific request, output, and billing unit |
| Anthropic Messages | No OpenAI SDK method | Use the Anthropic-compatible client surface |
The public OpenAPI document is the route-level contract.
Base URL migration map
| Service | OpenAI SDK base URL | Model namespace |
|---|---|---|
| OpenAI | https://api.openai.com/v1 | OpenAI IDs |
| OpenRouter | https://openrouter.ai/api/v1 | OpenRouter slugs |
| KeepRouter | https://keeprouter.com/v1 | KeepRouter 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
| Symptom | Check first |
|---|---|
| 401 | Key exists in the running process, has no extra whitespace, is not revoked, and reaches the KeepRouter host |
| 404 | Base URL includes exactly one /v1 and application code did not append /chat/completions |
| Model not found | Use an exact current KeepRouter ID; OpenAI and OpenRouter IDs do not transfer |
| Endpoint not supported | The model page lists the operation the SDK method calls |
| Streaming stops | Selected route support, SSE parsing, cancellation, and bounded retries |
| Tool continuation fails | Complete tool result, required prior messages, and the exact model |
| Browser exposes a key | Move 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