EN ▾
Get API key

Ollama API Base URL: Switch to a Hosted Endpoint

Isometric illustration of a cable moving from a local server to a hosted cloud endpoint

If you ask what the Ollama API base URL is, the local answer is http://localhost:11434 with an OpenAI-style route under /v1. This page shows what changes when you point the same client at a hosted endpoint instead.

Updated

Key points

  • Local Ollama listens on port 11434; a hosted API gives you one HTTPS base URL and a bearer key instead.
  • Here the base URL is https://api.ollamauncensored.cc/v1 and the model ID is uncensored.
  • Any OpenAI SDK works after you change two values: base URL and API key.
  • Most failures come from a missing /v1, a doubled path, or an empty key.

The short answer

A default Ollama install runs a server on your own machine. Its native routes live under http://localhost:11434/api/, and it also exposes an OpenAI-style layer under http://localhost:11434/v1/. That second address is the one most tools mean when they ask for a base URL. Because it speaks the OpenAI chat format, you can aim the same code at a different server by editing one string.

For the hosted endpoint on this site, the values are:

SettingValue
Base URLhttps://api.ollamauncensored.cc/v1
Chat routePOST /v1/chat/completions
Model listGET /v1/models
Model IDuncensored
Auth headerAuthorization: Bearer YOUR_KEY

That is the whole setup. The rest of this page covers the details that trip people up: where the path ends, which tools want the /v1 suffix and which add it themselves, and how to confirm the connection works before you wire it into anything bigger.

Local base URL versus a hosted one

Running a model through Ollama means you own the hardware, the process and the port. The server usually binds to localhost, so only programs on the same machine can reach it. There is typically no key to manage, which is why many clients let you type any placeholder string into the key field. You pay in electricity and GPU memory, and your context size is whatever your card can hold.

A hosted endpoint moves all of that off your machine. You get a public HTTPS address, so the base URL no longer says localhost and the port disappears. Access is controlled by a key sent as a bearer token. Your laptop can be a thin client, and so can a small server, a serverless function or a phone app. The model here is a single open-weight model run by an independent provider, with a 100,000-token context window shared between prompt and completion.

One thing does not carry over. Ollama has its own native API at /api/chat and /api/generate, with its own request shape. The hosted service does not implement those. It implements the OpenAI-compatible routes only, which is what the /v1 in the base URL refers to. If a tool offers both an "Ollama" connection type and an "OpenAI-compatible" one, pick the OpenAI-compatible type for this endpoint.

Python with the OpenAI SDK

The official openai package accepts a base_url argument. Install it with pip install openai, then:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.ollamauncensored.cc/v1",
    api_key="YOUR_KEY",
)

resp = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Explain what a base URL is in two sentences."},
    ],
)
print(resp.choices[0].message.content)

If you would rather keep values out of source files, the SDK reads two environment variables when you pass nothing: OPENAI_API_KEY and OPENAI_BASE_URL. Export them in your shell or put them in the process manager's config, and the constructor becomes OpenAI() with no arguments. This is also the least invasive way to retarget an existing program, because you change no code at all.

export OPENAI_BASE_URL="https://api.ollamauncensored.cc/v1"
export OPENAI_API_KEY="YOUR_KEY"
python app.py

You still need to change the model argument. Code written for local Ollama usually names something like a tag from your own library; here the only ID is uncensored.

Node and plain curl

The JavaScript SDK works the same way, with the option spelled baseURL:

import OpenAI from "openai";

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

const stream = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Give me three names for a fantasy tavern." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Streaming uses server-sent events and ends with a usage chunk, so you can log token counts without a second call. For a first smoke test, curl is faster than writing a program. Run the model list first, since it costs nothing and proves both the URL and the key:

curl https://api.ollamauncensored.cc/v1/models   -H "Authorization: Bearer YOUR_KEY"

curl https://api.ollamauncensored.cc/v1/chat/completions   -H "Authorization: Bearer YOUR_KEY"   -H "Content-Type: application/json"   -d '{"model":"uncensored","messages":[{"role":"user","content":"Say hello."}]}'

A JSON body with a choices array means the base URL is right. The response headers also include X-Balance-USD, which shows your remaining prepaid credit, and X-Request-Id, which is useful if you ever contact support about a specific call.

Chat frontends and agent tools

Most desktop and web chat apps ask for the same three things: a URL, a key and a model name. In SillyTavern, for example, you choose the Chat Completion API, then the custom OpenAI-compatible source, and paste the base URL, key and model ID. Open WebUI, LibreChat and similar apps have an "add OpenAI-compatible connection" screen that works the same way. Label names change between versions, so match by meaning rather than exact wording.

Two habits save time. First, paste the URL with the /v1 suffix unless the tool's field is explicitly described as "server address" and adds the path itself; if you get a 404, try the other form. Second, if the app fetches the model list automatically, it calls GET /v1/models and should show uncensored. When the list stays empty, the usual cause is a wrong key or a URL that stops one segment short.

The 100,000-token context window is shared between your prompt and the reply, so long roleplay histories and large documents fit with room to spare. Set your frontend's context limit to match, or it may trim history earlier than it needs to. The step-by-step version of a first call, with a working request, is in the quick-start docs.

Common mistakes and how to fix them

  • 404 on the chat route. The URL is missing /v1, or the tool appended it a second time and you have /v1/v1/chat/completions. Check the exact path the client logs.
  • 401 or an auth error. The key is empty or has a stray space or newline. Local setups often accept a dummy key, so a leftover placeholder like ollama is a frequent culprit.
  • Connection refused to localhost. The client still points at port 11434. Search your config, .env files and any OLLAMA_HOST style variable for the old address.
  • Model not found. The code still names a local model tag. Use uncensored.
  • Native Ollama client fails. A library that calls /api/chat will not work. Switch it to its OpenAI-compatible mode.
  • HTTP 429. You hit a limit. The error code rate_limited means too many requests per minute, concurrency means too many at once. A 429 with a Retry-After: 5 header means temporary overload, so wait five seconds and retry.

On limits: a full key allows 8 concurrent requests and 300 requests per minute, and a trial key allows 2 and 60. A streamed request holds its concurrency slot until the stream finishes, so a UI that opens many streams at once reaches the ceiling sooner than the request count suggests. Request bodies can be up to 8 MB.

Keeping local and hosted side by side

You do not have to give up the local server. Plenty of people keep Ollama for quick experiments and use a hosted endpoint when they need a bigger context window or want to stop caring about GPU memory. The easy way to do both is to keep the base URL, model name and key in a config file or environment, then switch profiles with one variable.

# .env.hosted
OPENAI_BASE_URL=https://api.ollamauncensored.cc/v1
OPENAI_API_KEY=YOUR_KEY
MODEL=uncensored

# .env.local
OPENAI_BASE_URL=http://localhost:11434/v1
OPENAI_API_KEY=placeholder
MODEL=your-local-tag

Load whichever file you need before starting your program. Because both profiles use the OpenAI request shape, the application code does not branch on the provider. Differences to expect: the hosted side enforces rate limits and a key, the local side enforces your own hardware. Responses on the hosted side also include the balance and rate-limit headers listed earlier, which a local server will not send.

Getting a key and paying for it

The base URL is public, but every call needs a key. New accounts can sign up with Google or with email and password, then claim $0.50 of trial credit with one click on the key page. It needs no card, is limited to one per person, and stays valid for 7 days. The page at get your API key walks through it.

After that, billing is prepaid and pay as you go: $0.15 per 1M input tokens and $0.50 per 1M output tokens, with no subscription. Failed or refused requests are not charged, and credit does not expire. Top-ups are any whole amount from $20 to $500 by crypto (USDT on TRC20, USDC on Base), with a bonus of 5% from $50, 10% from $100 and 15% from $200. The pricing page has the full table. Prompts are not used for training.

Because the endpoint takes standard OpenAI-style requests, moving between a local Ollama server and this one is a config change. Keep both base URLs in environment variables and you can switch with one line.

Questions and answers

What is the default Ollama API base URL?

A local Ollama server listens on http://localhost:11434. Its OpenAI-style layer is at http://localhost:11434/v1, which is the value most OpenAI-compatible clients expect.

What base URL do I use for this hosted API?

Use https://api.ollamauncensored.cc/v1 with the model ID uncensored and a bearer key. The chat route is POST /v1/chat/completions.

Can I use Ollama's native /api/chat route here?

No. Only the OpenAI-compatible routes, POST /v1/chat/completions and GET /v1/models, are available. Switch your client to its OpenAI-compatible mode.

Do I need a key if I only used localhost before?

Yes. Local servers often ignore the key, but the hosted endpoint requires a valid bearer key on every request.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.