EN ▾
https://api.mistralbaseurl.com/v1uncensored
Open account
mistralbaseurl.com

Last updated

Mistral Base URL: Point the OpenAI SDK at Our API

The mistral base url you need depends on whose API you call. For this service it is https://api.mistralbaseurl.com/v1, and any OpenAI SDK uses it once you set the base URL and an API key. This is a hosted, OpenAI-compatible API running its own open-weight model, not Mistral's platform; for Mistral's endpoint, use the value in their documentation.

Isometric junction with a lever redirecting a stream of light to a server tower, picturing a changed API base URL

The values you need

Four settings cover the whole connection. Everything else is standard OpenAI-style request code.

SettingValue
Base URLhttps://api.mistralbaseurl.com/v1
Chat endpointPOST /v1/chat/completions
Model IDuncensored
Auth headerAuthorization: Bearer YOUR_API_KEY

The API also serves POST /v1/responses and GET /v1/models. Get a key on the API key page; new accounts can claim $0.50 of trial credit there with one click.

How base_url actually works

OpenAI SDKs build every request URL by joining the base URL with an endpoint path. With the default base https://api.openai.com/v1, a chat call goes to https://api.openai.com/v1/chat/completions. When you change the base, only the front part of that address changes.

That is why the /v1 belongs in the base URL and not in your request code. Set https://api.mistralbaseurl.com/v1 and the SDK sends chat requests to https://api.mistralbaseurl.com/v1/chat/completions. Leave /v1 off and you get a 404, because the path the server sees is missing a segment.

The base URL changes only where the SDK sends requests. The request body, headers and response still follow the OpenAI chat completions shape, which is why your existing client code keeps working. Write the base exactly as shown, with no trailing slash, so every client joins paths the same way.

Python and Node.js

Python

Install the official package with pip install openai, then pass base_url when you build the client.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.mistralbaseurl.com/v1",
    api_key="YOUR_API_KEY",
)

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(resp.choices[0].message.content)

Nothing else changes. Streaming, tool calling and JSON mode use the same parameters you already know; the docs list what is passed through.

Node.js

The Node SDK spells the option baseURL. Install with npm install openai.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.mistralbaseurl.com/v1",
  apiKey: process.env.API_KEY,
});

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Say hello in five words." }],
});
console.log(resp.choices[0].message.content);

Top-level await needs an ES module, so use a .mjs file or set "type": "module" in package.json.

curl, environment variables and config

A raw request is the quickest way to prove the URL and key work, independent of any SDK.

curl https://api.mistralbaseurl.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","messages":[{"role":"user","content":"Say hello in five words."}]}'

The official OpenAI SDKs also read two environment variables, so you can switch endpoints without editing code. Set them in your shell, a .env loader or your deployment config:

export OPENAI_BASE_URL="https://api.mistralbaseurl.com/v1"
export OPENAI_API_KEY="YOUR_API_KEY"

With those set, OpenAI() in Python or new OpenAI() in Node needs no arguments. Keep the key out of source control and out of front-end code.

For a GUI client the routine is nearly always the same: choose the OpenAI-compatible or custom provider option, paste the base URL, paste the key, enter the model name, and send a test message. Some clients fill a model dropdown from GET /v1/models, so if the list stays empty, recheck the URL before anything else.

Hard-coding an endpoint makes it painful to move between environments. Read the base URL and key from settings, and give the base a default.

import os
from openai import OpenAI

client = OpenAI(
    base_url=os.environ.get("LLM_BASE_URL", "https://api.mistralbaseurl.com/v1"),
    api_key=os.environ["LLM_API_KEY"],
)
MODEL = os.environ.get("LLM_MODEL", "uncensored")

With this pattern, staging, local development and production differ only in environment values. If you ever want to compare two providers, you run the same code with two sets of variables and diff the outputs. Store keys in your platform's secret manager rather than in a committed .env file, and add .env to .gitignore.

Check which URL the client really uses

When an environment variable and a constructor argument both exist, the explicit argument wins, so an old value left in code can quietly override the one you exported. Print what the client holds before you debug anything else.

from openai import OpenAI

client = OpenAI()
print(client.base_url)

In Node the same value is client.baseURL. The printed address should match https://api.mistralbaseurl.com/v1. If it shows the default OpenAI address, your variable did not load: check the shell session, the process manager or the container settings that start your app. Restart the process after changing environment values, since most runtimes read them once at start-up.

A ten-line health check

Before you blame your application, run a script that touches the minimum surface: list models, then send one tiny chat call and print the balance header.

from openai import OpenAI

client = OpenAI(base_url="https://api.mistralbaseurl.com/v1", api_key="YOUR_API_KEY")

print([m.id for m in client.models.list().data])

raw = client.chat.completions.with_raw_response.create(
    model="uncensored",
    messages=[{"role": "user", "content": "ping"}],
    max_tokens=5,
)
print(raw.parse().choices[0].message.content)
print("balance:", raw.headers.get("X-Balance-USD"), "request id:", raw.headers.get("X-Request-Id"))

If the first line fails, the base URL or key is wrong. If only the second fails, look at the body fields or the model name. Keep the X-Request-Id value when you write to support; it identifies the exact call.

The Responses endpoint on the same base

The same base URL serves POST /v1/responses as well as chat completions. Recent versions of the official Python SDK expose it as client.responses, so you can use whichever style your code already follows.

from openai import OpenAI

client = OpenAI(base_url="https://api.mistralbaseurl.com/v1", api_key="YOUR_API_KEY")

resp = client.responses.create(
    model="uncensored",
    input="Say hello in five words.",
)
print(resp.output_text)

Both endpoints bill the same way: $0.15 per 1M input tokens and $0.50 per 1M output tokens, with failed requests not charged. Streaming, tool calling and JSON mode are described in the docs. If a request works on one endpoint and not the other, compare the paths first and the body second.

Other tools that ask for a base URL

Most OpenAI-compatible clients expose the same field under a different label: API base, base URL, endpoint or custom OpenAI server. Chat front ends such as SillyTavern let you add an OpenAI-compatible endpoint, and frameworks such as LangChain accept a base URL on their OpenAI chat class. Paste https://api.mistralbaseurl.com/v1, add your key, and type uncensored as the model name when the tool asks for one.

Some tools ask for the full chat completions address instead of the base. If the field says "endpoint" and the help text shows a URL ending in /chat/completions, use https://api.mistralbaseurl.com/v1/chat/completions.

Mistakes that break the connection

  • Missing /v1. https://api.mistralbaseurl.com alone gives 404 on chat calls.
  • Doubled path. A base of .../v1/chat/completions makes the SDK request .../v1/chat/completions/chat/completions.
  • Wrong model name. The model ID is uncensored, not a vendor model name copied from another tutorial.
  • Stray whitespace in the key. A trailing newline from a copied value causes an authentication error.
  • Plain http. Use https. Some clients turn a redirected POST into a GET, which then fails.

A quick sanity check is curl https://api.mistralbaseurl.com/v1/models -H "Authorization: Bearer $API_KEY". If it lists the model, the URL and key are fine and the problem is in your request body. For a fuller walkthrough of moving an existing Mistral-style project, read the Mistral API integration guide. Rates are on the pricing page.

If requests fail only from an office or school network, ask the network team to allow outbound HTTPS to api.mistralbaseurl.com. The Python client honors the standard HTTPS_PROXY variable, so a required corporate proxy can usually be set without touching your code.

Common questions

What is the base URL for this API?

It is https://api.mistralbaseurl.com/v1. Include the /v1 and leave off /chat/completions, which the SDK adds itself.

Is this Mistral's official base URL?

No. This is an independent OpenAI-compatible API running one open-weight model. For Mistral's own endpoint, use the address in Mistral's documentation.

Which model name do I send?

Send uncensored as the model ID in every request.

Can I set the base URL with an environment variable?

Yes. The OpenAI Python and Node SDKs read OPENAI_BASE_URL and OPENAI_API_KEY, so no code change is needed.

Get your API key now

Sign up, grab your key, update your base URL. That is all.