Ollama API URL: Default Port and Base URL
The default ollama api url is http://localhost:11434, and the OpenAI-compatible base URL is that address plus /v1. Below: which URL each tool wants, how to change it, and what to use when you switch to a hosted API.
Last updated

Summary
- Prepaid billing with no monthly fees means you only pay for what you use.
- Our uncensored model runs on dedicated servers, not as a local proxy.
- Crypto-only top-ups from $20 to $500 include bonus credit tiers.
- Streaming, function calling, and JSON mode are fully supported.
The default URL in one table
Out of the box, the Ollama server listens on port 11434 of your own computer. The ollama api url you need depends on which API a tool speaks.
| Use | URL |
|---|---|
| Server root (health check) | http://localhost:11434 |
| Native chat | http://localhost:11434/api/chat |
| Native generate | http://localhost:11434/api/generate |
| List local models | http://localhost:11434/api/tags |
| OpenAI-style base URL | http://localhost:11434/v1 |
| OpenAI-style chat | http://localhost:11434/v1/chat/completions |
Opening the root address in a browser shows a short message saying the server is running. That makes it a quick health check: if the page does not load, the server is not running or the URL is wrong.
Localhost and 127.0.0.1 usually mean the same thing. If a tool fails on localhost, try 127.0.0.1, because some systems resolve localhost to an IPv6 address first.
Base URL versus full endpoint URL
This is where most mistakes happen. An OpenAI-style client wants the base URL, and adds /chat/completions itself. If you paste the full endpoint into a base URL field, the client requests something like .../chat/completions/chat/completions and gets a 404.
- Base URL field:
http://localhost:11434/v1 - Full endpoint, used only in raw HTTP calls:
http://localhost:11434/v1/chat/completions
The reverse mistake also exists. A tool that expects the native API wants the root address, http://localhost:11434, and adds /api/chat itself. Giving it /v1 breaks it. If you see 404 errors, read the tool's documentation to learn whether it speaks the native or the OpenAI protocol.
Two smaller points: a missing scheme (localhost:11434 without http://) works in some tools and fails in others, and a trailing slash is usually harmless. Keep both consistent with the tool's examples.
Changing the host or port
The OLLAMA_HOST environment variable sets the address and port the server uses. Typical values are 127.0.0.1:11434 (default), 127.0.0.1:8080 (a different port) and 0.0.0.0:11434 (all network interfaces). The client side uses the same variable to know where to connect when you run command line commands against a server elsewhere.
How you set it depends on how Ollama runs. In a shell, export it before starting the server. Under systemd on Linux, add it through a service override. On macOS with the desktop app, set it with launchctl and restart the app. On Windows, use the system environment variables and restart the Ollama process.
Be careful with 0.0.0.0. The server has no authentication, so anyone who can reach that port can use it. If you only need access from another computer, forward a port over SSH or use a private network instead. The article on uncensored LLM API alternatives compares options if you decide not to self-host.
Docker, WSL and other special cases
The default URL assumes the client and server share a network namespace. When they do not, localhost points at the wrong place.
- Client inside Docker, Ollama on the host. Inside the container, localhost is the container itself. On Docker Desktop use
http://host.docker.internal:11434. On Linux, add a host-gateway mapping or use the host's network address. - Ollama inside Docker. Publish the port, for example with
-p 11434:11434. To keep it private, publish to127.0.0.1:11434:11434. - WSL and Windows. A server on one side may not appear as localhost on the other, depending on your networking mode. Test with curl from the failing side.
- Remote server. Use the server's address, for example
http://192.168.1.50:11434, only after setting the bind address and opening the firewall for trusted sources.
When in doubt, test from the exact place where your app runs, not from where you happen to have a terminal.
The base URL for a hosted API
A hosted OpenAI-compatible API is also just a base URL. For this service it is:
https://api.ollamaapiurl.com/v1
The routes below it are POST /chat/completions, POST /responses and GET /models. Requests are authenticated with Authorization: Bearer <key>, and the model ID is uncensored. Because the base URL already ends in /v1, never add another /v1 in your client.
from openai import OpenAI
# Local Ollama
local = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
# Hosted API (same SDK, different values)
hosted = OpenAI(base_url="https://api.ollamaapiurl.com/v1", api_key="YOUR_API_KEY")
print(hosted.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Reply with the word ready."}],
).choices[0].message.content)
The same works from curl and Node. Set the base URL in the client constructor, or use the SDK's environment variable for it (OPENAI_BASE_URL in current OpenAI SDKs) together with OPENAI_API_KEY, which lets you switch targets without editing code.
Setting the URL once, through environment variables
Hardcoding a URL in several files is how you end up with half of an app talking to localhost and half to production. Read it from the environment in one place. The Node example below does that, so the same file runs against a local Ollama in development and the hosted API in production, only the variables change.
import OpenAI from "openai";
// Development: BASE_URL=http://localhost:11434/v1 API_KEY=ollama MODEL=llama3.2
// Production: BASE_URL=https://api.ollamaapiurl.com/v1 API_KEY=<your key> MODEL=uncensored
const client = new OpenAI({
baseURL: process.env.BASE_URL ?? "https://api.ollamaapiurl.com/v1",
apiKey: process.env.API_KEY,
});
const res = await client.chat.completions.create({
model: process.env.MODEL ?? "uncensored",
messages: [{ role: "user", content: "Say which server you are." }],
});
console.log(res.choices[0].message.content);
Keep the key out of the repository and out of front-end code, since anyone can read a key shipped to a browser.
Which error tells you what
The kind of failure tells you what is wrong with the URL.
| Symptom | Likely cause |
|---|---|
| Connection refused | Server not running, wrong port, or bound to a different address |
| Timeout | Firewall dropping packets, or a wrong IP address |
| 404 Not Found | Wrong path: a doubled /v1, or a full endpoint in a base URL field |
| 401 Unauthorized | Hosted API: missing or wrong bearer key |
| Model not found | Name does not exist on that server; use uncensored on the hosted API |
| 429 Too Many Requests | Hosted API: rate_limited or concurrency; wait and retry |
One more pattern: the request works from curl but fails from your app. Then the URL is fine and the app is doing something different, such as adding its own path, using a proxy setting from the environment, or sending the call from a browser, where cross-origin rules apply. Print the exact URL your client builds before you suspect the server.
Fix them in that order. A URL problem hides everything behind it, so confirm the address with curl before you adjust prompts, parameters or keys.
What to type into popular clients
Most chat frontends, coding assistants and roleplay apps share the same three fields. Labels differ, but the values are the same:
- API type or provider: choose "OpenAI-compatible" or "custom OpenAI" (not "Ollama", which expects the native API).
- Base URL, API URL or endpoint:
https://api.ollamaapiurl.com/v1. Some apps want the full chat URL; if so, append/chat/completions. - API key: your bearer key from the API key page.
- Model:
uncensored.
# Verify the URL, key and model before you configure any app
curl https://api.ollamaapiurl.com/v1/models -H "Authorization: Bearer $API_KEY"
curl https://api.ollamaapiurl.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"uncensored","messages":[{"role":"user","content":"ping"}]}'
If the first call returns your model list and the second returns a reply, the URL is right, and any remaining failure is inside the app. A 401 means the key is wrong. A 429 means a limit: a trial key allows 2 concurrent requests and 60 per minute, a full key 8 and 300. Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, with details on the pricing page, and parameters in the docs. New users can claim $0.50 of trial credit with one click after sign-up. It is valid for 7 days and needs no card.
More guides
Frequently asked questions
What is the default Ollama API URL?
http://localhost:11434. Native routes are under /api, and the OpenAI-compatible base URL is http://localhost:11434/v1.
Why do I get 404 on /v1/chat/completions/chat/completions?
You put the full endpoint in a base URL field. Enter only the base URL ending in /v1 and let the client add the rest.
How do I change the Ollama port?
Set OLLAMA_HOST, for example to 127.0.0.1:8080, and restart the server. Then update the URL in your clients.
What is the hosted base URL on this site?
https://api.ollamaapiurl.com/v1, with model ID uncensored and a bearer key.
Get your API key in one step
Sign up, copy the key, update your base URL. Simple as that.