Guide · Code & SDK

How to move code from the OpenAI SDK to other models: changing base_url

How to move code from the OpenAI SDK to DeepSeek, Gemini, Qwen and GPT models: base_url and key in Python, Node, curl, environment variables and LangChain.

5 min time
Python, Node, curl stack
2 lines of code
Beginner level

Many projects that work with neural networks use the OpenAI SDK: the official openai packages for Python and Node, LangChain, and other tools and frameworks. All of them can be switched to models from other vendors without a rewrite: you only change the API address and the key. This guide shows where exactly the base URL is set in each environment and what to check after the move.

What changes

An OpenAI-compatible client has three settings: the API address (base URL), the key and the model name. The llmbox address is the same for every client:

text
https://llmbox.cc/v1

The address already includes /v1, and the SDK adds request paths such as /chat/completions, /responses and /models on its own. Create a key in the cabinet, in the Keys section. A model identifier looks like vendor/model, for example deepseek/deepseek-v4.1-flash or openai/gpt-5.6-sol. In all the examples below, the key is read from the LLMBOX_API_KEY environment variable.

Python

In the openai package, the address and key are passed as client parameters. The rest of your code stays as it is.

python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://llmbox.cc/v1",
    api_key=os.environ["LLMBOX_API_KEY"],
)
resp = client.chat.completions.create(
    model="deepseek/deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)

The asynchronous AsyncOpenAI client takes the same base_url and api_key parameters.

Node.js

In the openai package for Node, the parameter is called baseURL.

ts
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://llmbox.cc/v1",
  apiKey: process.env.LLMBOX_API_KEY,
});
const resp = await client.chat.completions.create({
  model: "deepseek/deepseek-v4.1-flash",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);

curl and any HTTP client

Without an SDK, you send a plain POST request with the key in the Authorization header. You can send such a request from any language that has an HTTP client.

bash
curl https://llmbox.cc/v1/chat/completions \
  -H "Authorization: Bearer $LLMBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v4.1-flash",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Environment variables

If you don't pass parameters to the client, the official SDKs read the address and key from the OPENAI_BASE_URL and OPENAI_API_KEY variables. This way you can leave finished code untouched and switch the connection through the environment.

bash
export OPENAI_BASE_URL=https://llmbox.cc/v1
export OPENAI_API_KEY=$LLMBOX_API_KEY

After that, OpenAI() in Python and new OpenAI() in Node without parameters send requests to llmbox. The same applies to libraries that create an OpenAI client internally. All that remains is to change the model value to an identifier from the catalog.

LangChain

LangChain connects through the standard ChatOpenAI class: set the address, the key and the model identifier. For Python, install the package with pip install langchain-openai; for JS, run npm install @langchain/openai @langchain/core.

import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://llmbox.cc/v1",
    api_key=os.environ["LLMBOX_API_KEY"],
    model="openai/gpt-5.6-sol",
)
print(llm.invoke("Hello").content)

To switch the model in LangChain chains and agents, change the model value. llm.stream(...) returns the response in parts, and bind_tools enables function calling. For embeddings, use OpenAIEmbeddings with a model from the catalog.

Ready-made tools

The same approach works in programs that let you set your own OpenAI API address. Enter the llmbox address, a key from the cabinet and a model identifier from the catalog. Step-by-step setups are collected in the documentation:

ToolWhere to set the address
OpenCodebaseURL in the llmbox entry of the config
ClineBase URL in the OpenAI Compatible settings
Open WebUIThe OpenAI API connection URL
n8nBase URL in the OpenAI credentials

The full list with formats and variables is in the documentation page Integrations overview.

Comparing models with one codebase

Once the address and key are set, models from different vendors are called with the same code. Try a few models on a typical request from your project and compare the answers and token usage.

python
models = [
    "deepseek/deepseek-v4.1-flash",
    "google/gemini-3.8-flash",
    "qwen/qwen3.8-flash",
    "openai/gpt-5.6-sol",
]
for model in models:
    resp = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "Shorten to one sentence: ..."}],
    )
    print(model, resp.usage.total_tokens)
    print(resp.choices[0].message.content, "\n")

Checking after the move

Usually the code works right after the address change. If something goes wrong, check four things.

  • Model identifier. A 404 model_not_found error means a typo or an old model name without the vendor. Compare it with the client.models.list() output.
  • Request format. A model works in the formats it supports: Chat Completions, Responses or both. Model formats are described in the documentation page API overview, and the details of a specific model are on its catalog page.
  • Parameters. Each format has its own parameter list: for example, in Responses the response cap is max_output_tokens, not max_tokens. The lists are in the documentation page Request parameters.
  • Conversation history. Pass the whole history in every request: as the messages list in Chat Completions, or as the input array in Responses.

The cost of every request after the move is visible in the Logs section of the cabinet: status, model, tokens and cost.

Questions

What is an OpenAI-compatible API?

An API that accepts requests and returns responses in the OpenAI format. The official openai SDKs and any tool that lets you set a custom base URL work with it.

What else do I need to change in the code besides base_url and the key?

The value of the model field: in llmbox a model identifier looks like vendor/model, for example openai/gpt-5.6-sol. The rest of the code, including messages, streaming and functions, stays the same.

Where can I get the list of model identifiers?

In the catalog on the site or with a GET /v1/models request. In Python that is client.models.list(), in Node it is client.models.list() with await.

Do streaming and function calling work?

Yes. Streaming is turned on with the stream parameter, and functions from tools are passed to the model as they are. The parameters available in each format are described in the Request parameters section of the documentation.

Published November 15, 2026

One key — every model

GPT, Gemini, DeepSeek, Qwen, video and audio. Pay as you go.

Create a key