BroadRouter
Get started

Base URL

Updated

A base URL is the fixed root address of an API, such as https://api.example.com/v1, that a client puts in front of every endpoint path, such as /chat/completions. In OpenAI-compatible SDKs, changing the base URL, together with the API key and model ID, points the same code at a different provider.

Also called: API base URL, api_base, baseURL, OPENAI_BASE_URL, endpoint URL

Every request an SDK makes is the base URL plus a path. Get the base URL right and the rest of the client works unchanged.

How it works

The client joins two parts:

Part Example
Base URL https://inference.broadnet.ai/v1
Endpoint path /chat/completions
Full request URL https://inference.broadnet.ai/v1/chat/completions

In code, the parameter name depends on the library:

# Python SDK
client = OpenAI(base_url="https://inference.broadnet.ai/v1", api_key=os.environ["BROADNET_API_KEY"])
// Node SDK
const client = new OpenAI({ baseURL: "https://inference.broadnet.ai/v1", apiKey: process.env.BROADNET_API_KEY });

Both official SDKs fall back to the OPENAI_BASE_URL environment variable, and to OpenAI’s own address when nothing is set. Other tools use names such as api_base or OPENAI_API_BASE.

Why it matters

The base URL is what makes an OpenAI-compatible API a drop-in change. It also decides where your prompts go and who bills you. A wrong value can send traffic, and your API key, to the wrong provider. Keep it in configuration next to the key, not hard-coded in several places.

Routers use the same idea: you point the base URL at the router instead of at a model provider.

On BroadNet Inference

The base URL is https://inference.broadnet.ai/v1 for every model: chat, vision and speech to text. Chat goes to /chat/completions and transcription to /audio/transcriptions. The curl quickstart shows a first request, and the LangChain guide shows where the setting lives in a framework.

Common mistakes

  • Missing /v1. https://inference.broadnet.ai without /v1 produces 404 errors from the SDK.
  • Doubled path. Pasting the full endpoint, such as .../v1/chat/completions, as the base URL makes the SDK call .../chat/completions/chat/completions.
  • Leftover environment variables. An old OPENAI_BASE_URL in your shell overrides what you expect. Print it when requests go to the wrong place.
  • Plain HTTP. Always use https://. Bearer keys must travel over TLS.
  • Changing the URL but not the model. Each provider has its own model IDs, such as broadnet/deepseek-v4.1-flash.

Moving a whole app? Work through the migration checklist.

Questions

Should the base URL end in /v1?

For OpenAI-compatible SDKs, yes, when the provider's paths start with /v1. The SDK then appends paths such as /chat/completions. Check the provider's docs for the exact value.

Can I set the base URL without changing code?

Yes. The official OpenAI Python and Node SDKs read the OPENAI_BASE_URL environment variable when you do not pass a base URL. Some tools use their own variable names, such as OPENAI_API_BASE in Aider.

What is the BroadNet Inference base URL?

https://inference.broadnet.ai/v1

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity