Docs
OpenAI base URL: Python and Node.js setup
Configure an OpenAI-compatible base URL in Python or Node.js. Check the /v1 path, API key and model ID, then troubleshoot 401 and 404 responses.
Which base URL should I use?
For EasyAI, use https://easyairoute.com/v1. Set base_url in the Python OpenAI client or baseURL in the Node.js client. The SDK adds the endpoint path; do not put /chat/completions in the base URL.
The standard OpenAI API uses https://api.openai.com/v1. An OpenAI key belongs with the OpenAI endpoint; an EasyAI key belongs with the EasyAI endpoint. Changing the URL does not transfer credentials, balance, or model access between providers.
A compatible request format does not guarantee every OpenAI feature. Confirm the selected model and endpoint in the model catalog and compatibility notes before enabling streaming, tools, images, or Responses API requests.
Python: configure base_url
Install the openai package with pip install openai. Set EASYAI_API_KEY in your server environment. This example lists the models visible to your key before you choose a model for a generation request.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["EASYAI_API_KEY"],
base_url="https://easyairoute.com/v1",
)
for model in client.models.list().data:
print(model.id)Node.js: configure baseURL
Install the package with npm install openai. Run this example on your server with EASYAI_API_KEY set. Python uses base_url; JavaScript and TypeScript use baseURL with a capital URL.
import OpenAI from "openai";
const apiKey = process.env.EASYAI_API_KEY;
if (!apiKey) throw new Error("Set EASYAI_API_KEY on the server");
const client = new OpenAI({
apiKey,
baseURL: "https://easyairoute.com/v1",
});
const models = await client.models.list();
for (const model of models.data) console.log(model.id);Environment variables and the /v1 path
The Python SDK also accepts OPENAI_BASE_URL as an environment variable. EASYAI_API_KEY is an application-defined name in these examples, so it is passed explicitly to api_key or apiKey. Set variables in the process that runs the app; merely creating a .env file does not load it into every runtime.
With https://easyairoute.com/v1 as the base, a model-list request should reach https://easyairoute.com/v1/models. A chat request should reach https://easyairoute.com/v1/chat/completions. If you see /v1/v1 or /chat/completions/chat/completions in a request path, check whether your SDK or integration has already appended that segment.
Some third-party tools ask for an origin, while others ask for a complete API base. Follow that tool's setting description and inspect the final request URL. Never include an API key in the URL or diagnostic screenshots.
Troubleshoot 401, 404 and model access
401: confirm that the key is present, has not been revoked, and was issued by the provider receiving the request. Check the Authorization header without printing the credential. Repeating the same request will not fix an invalid key.
404 or an HTML response: inspect the final host and path. A missing or duplicated /v1, a website URL, or an unsupported endpoint can reach the wrong handler. Read the error body before deciding that the model is unavailable.
A successful model list confirms connectivity and authentication for that endpoint. It does not prove that every listed model supports your chosen operation. Copy an exact model ID, check its supported endpoint and current account price, then make a small test request.
For a 429 response, read the error body to distinguish a rate limit from an account quota issue. Use bounded backoff for transient limits and check account balance when the error indicates insufficient quota.
Before migrating an application
Keep the URL, key, and model ID in server-side configuration. Compare representative responses, streaming chunks, usage fields, errors, and cost before moving a production workload. Keep the previous configuration available for rollback.
Next, use the Python or Node.js generation examples, review compatibility, and check model pricing. Keep API keys out of browser code and public repositories.
Sources
Reviewed .