On this page
- The short version
- Understand the request path first
- Step 1: make sure the model actually runs in Ollama
- Step 2: verify the API locally
- Step 3: configure the AI client
- Model names must match what Ollama knows
- Connecting from another computer
- Connecting to Ollama from an iPhone
- Why authentication deserves attention
- HTTP is normal on a private LAN, but scope it carefully
- Which OpenAI-compatible features work?
- Context length can surprise you
- First-token delay is not always a networking problem
- Common Ollama connection failures
- The client says connection refused
- It works on the Mac but not on the iPhone
- The server responds, but the model is not found
- Basic chat works but tools or images fail
- The response starts but the UI behaves strangely
- Long chats suddenly become slow
- Ollama native API vs OpenAI-compatible API
- When Ollama is a good fit
- A reliable setup checklist
Ollama is one of the simplest ways to run language models on hardware you control. But after you can run a model from the terminal, a second question appears: how do you use that Ollama model from a normal AI chat client?
The cleanest answer is usually Ollama’s OpenAI-compatible API.
That interface lets a client that already understands OpenAI-style requests connect to Ollama by changing three things:
- the base URL;
- the model identifier;
- the authentication configuration.
The model still runs through Ollama. The compatibility layer only changes how the client talks to it.
The short version
For a chat client running on the same computer as Ollama, the connection commonly looks like:
Base URL: http://localhost:11434/v1
Model: your Ollama model name
API key: not required by the local Ollama server
Some OpenAI SDKs insist that an API-key field is non-empty even when the server does not authenticate local requests. In that case a placeholder may be required by the SDK, but the local Ollama server itself does not need that credential.
For a client on another device, such as an iPhone, localhost will not work. You need to expose Ollama on the private network and use the host computer’s LAN address instead.
That distinction causes more connection failures than almost anything else.
Understand the request path first
A local Ollama setup has three independent pieces:
AI chat client
↓
Ollama HTTP API
↓
local model
If all three are on the same Mac or PC, networking is easy because the client can use loopback.
If the chat client is on another device, the path becomes:
iPhone / laptop
↓ Wi-Fi or LAN
Mac / PC running Ollama
↓
local model
Now the operating system firewall, Wi-Fi isolation, server bind address, and client permissions matter too.
If you want the general networking model before the Ollama-specific steps, read Connect an OpenAI-Compatible Local Server from iPhone.
Step 1: make sure the model actually runs in Ollama
Do not debug the chat client before verifying Ollama itself.
First pull a model:
ollama pull <model-name>
Then run it directly:
ollama run <model-name>
Send a short prompt and confirm you get a response.
This proves several things at once:
- Ollama is installed correctly;
- the model exists locally;
- the model can load on your hardware;
- inference works independently of the external client.
If this step fails, changing the API base URL in another app will not fix the underlying problem.
Step 2: verify the API locally
Ollama normally exposes its local API on port 11434.
A simple model-list request is a useful test:
curl http://localhost:11434/v1/models
If that succeeds, the OpenAI-compatible layer is reachable.
You can also test a chat request directly:
curl http://localhost:11434/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "<model-name>",
"messages": [
{"role": "user", "content": "Reply with one short sentence."}
]
}'
Testing with curl is valuable because it removes the chat application’s UI, persistence, streaming renderer, and provider abstraction from the problem.
If curl fails locally, fix Ollama first. If curl works but the client fails, inspect the client’s connection settings.
Step 3: configure the AI client
A client that supports custom OpenAI-compatible providers usually asks for some version of these fields:
| Setting | Typical Ollama value |
|---|---|
| Provider type | OpenAI-compatible / custom |
| Base URL | http://localhost:11434/v1 |
| Authentication | None, when supported |
| Model | Exact Ollama model identifier |
| Streaming | Enabled if the client supports it |
The important detail is the /v1 suffix. Ollama has its own native API paths as well, but an OpenAI-compatible client expects the compatibility endpoints.
If the app has a model discovery button, it may be able to read /v1/models. If discovery does not work, manual model entry can still work perfectly.
Model names must match what Ollama knows
Do not assume a model’s marketing name is its API identifier.
The safest choices are:
ollama list
or the compatible model-list endpoint:
curl http://localhost:11434/v1/models
Then copy the exact identifier.
A request can fail even when the server is healthy if the client sends a model name that does not exist locally.
This is also why an error that looks like a provider failure may actually be a model-selection problem. For a structured diagnostic flow, see AI API Error 401 vs 403 vs 429, which also covers common 400 and 404 cases.
Connecting from another computer
localhost always means the device making the request.
If Ollama runs on a Mac at 192.168.1.50, another computer on the same network would need something like:
http://192.168.1.50:11434/v1
But changing the URL alone is not enough. Ollama normally binds to loopback for local access. To accept LAN connections, configure the server to listen beyond 127.0.0.1.
Ollama supports this through the OLLAMA_HOST server setting. A common LAN-oriented configuration is:
OLLAMA_HOST=0.0.0.0:11434
Binding to 0.0.0.0 means the service can listen on available network interfaces, so treat that as a security decision, not merely a connectivity trick.
After changing the server configuration, restart Ollama and test from the other device.
Connecting to Ollama from an iPhone
For an iPhone, four conditions must all be true:
- Ollama is listening on a LAN-reachable interface.
- The iPhone can route to the computer running Ollama.
- The host firewall allows the connection.
- The iPhone app has permission to access the local network when iOS requires it.
Then the base URL should use the host computer’s private address, not localhost:
http://192.168.1.50:11434/v1
A .local hostname may also work on networks where local name resolution is functioning:
http://my-mac.local:11434/v1
Private addresses can change when your router renews DHCP leases. If you rely on this workflow every day, a stable DHCP reservation or reliable local hostname is easier than repeatedly editing the endpoint.
Why authentication deserves attention
A local Ollama API does not require authentication in the ordinary localhost setup.
That is convenient when only your own process can reach it.
Once you expose the server to a network, however, network reachability becomes part of the security boundary. Anyone who can reach the port may be able to submit inference requests unless you add protection elsewhere.
On a trusted home LAN, you may accept that tradeoff. On shared Wi-Fi, office networks, dorm networks, or any environment you do not control, it deserves much more caution.
Useful protections include:
- keeping the server bound only to interfaces that need it;
- host firewall rules;
- placing authentication in front of Ollama through a trusted gateway or reverse proxy;
- using a VPN rather than exposing the raw service broadly;
- never forwarding port
11434directly to the public internet without an intentional security layer.
“Local model” and “secure endpoint” are not synonyms.
HTTP is normal on a private LAN, but scope it carefully
Local inference servers often use plain HTTP because TLS certificates add friction inside a private development network.
That can be reasonable when the traffic stays on a network you trust. It should not lead to a global “allow insecure HTTP everywhere” setting in the chat client.
A safer client policy is:
- HTTPS by default for internet endpoints;
- explicit opt-in for local HTTP;
- local HTTP limited to private, loopback, or link-local destinations.
This keeps a development convenience from becoming an internet-wide downgrade.
Which OpenAI-compatible features work?
“OpenAI-compatible” does not mean every OpenAI feature is reproduced exactly.
Ollama supports a useful subset of compatible endpoints and features, including ordinary chat completions, streaming, model listing, embeddings, tool calling for supported models, vision for suitable models, and reasoning controls for models that expose them.
But three layers still have to agree:
client capability
∩
Ollama compatibility support
∩
model capability
If any layer is missing a feature, the workflow can fail or fall back.
For example, a client may know how to send tool definitions, and Ollama may understand the tool-call format, but the selected model may be poor at producing valid tool calls.
That is why compatibility should be treated as a contract you test, not a badge that guarantees feature parity. See What Is an OpenAI-Compatible API? for a deeper explanation.
Context length can surprise you
A model may advertise support for a large context window, but your actual local setup can use a smaller configured context.
Context is not free. Larger context can increase memory use and prompt-processing cost, and parallel requests can multiply memory requirements.
If long conversations behave strangely, truncate unexpectedly, or cause large memory spikes, inspect the server’s configured context as well as the model’s theoretical maximum.
For a broader explanation of what context includes and why long chats eventually become expensive, see What Is an AI Context Window? once that concept becomes relevant to your setup.
First-token delay is not always a networking problem
A local server may respond slowly to the first request because the model needs to be loaded into memory.
That is different from slow generation.
When diagnosing local performance, separate:
- connection latency — can the client reach Ollama quickly?
- model load time — does the model need to enter memory?
- prompt processing — how long does the existing context take to evaluate?
- generation speed — how many tokens per second arrive after generation begins?
A model that is already warm may feel dramatically faster than the same model after it has been unloaded.
This also explains why a successful health check can be instant while the first real chat request is not.
Common Ollama connection failures
The client says connection refused
Check:
- Ollama is running;
- port
11434is correct; - the host is correct;
- Ollama is listening on the interface the client is trying to reach;
- the firewall is not blocking the connection.
It works on the Mac but not on the iPhone
The most likely problem is network scope.
localhost on the iPhone points to the iPhone. Use the Mac’s LAN address and ensure Ollama is listening beyond loopback.
The server responds, but the model is not found
Copy the identifier from ollama list or /v1/models. Do not guess it.
Basic chat works but tools or images fail
Verify all three layers: client support, Ollama compatibility, and selected-model capability.
The response starts but the UI behaves strangely
That may be a streaming-compatibility problem rather than an inference problem. Test a non-streaming request or inspect the raw events if the client offers a developer console.
Long chats suddenly become slow
Long context increases prompt-processing work. Also inspect model context settings and available memory.
Ollama native API vs OpenAI-compatible API
Ollama also has its own native API.
If you are building an Ollama-specific application, the native interface can expose Ollama semantics directly and may be the more natural choice.
For a general BYOK chat client, the compatible interface has a different advantage: portability.
The same provider abstraction can potentially connect to:
- Ollama;
- LM Studio;
- a company gateway;
- a hosted compatible endpoint;
- another self-hosted inference server.
That reduces the amount of client-specific integration needed for basic workflows.
When Ollama is a good fit
Ollama is especially useful when you want:
- inference on hardware you control;
- a simple local model runtime;
- private-network access from other devices;
- experimentation with different local models;
- an OpenAI-compatible interface for existing clients;
- local and cloud providers side by side.
It is less compelling when your main requirement is immediate access to the largest hosted models with no hardware management.
The tradeoff is explored in Local LLM vs Cloud AI API.
A reliable setup checklist
Before blaming the chat client, verify this sequence:
ollama run <model>works locally./v1/modelsresponds.- A direct
/v1/chat/completionsrequest works. - The client uses the
/v1base URL. - The configured model name exists.
- If remote, Ollama listens beyond loopback.
- The device can reach the host and port.
- Local-network permission and firewall rules allow the request.
- The authentication setting matches the actual deployment.
- Advanced features are supported by the client, Ollama, and the model.
Following that order turns an opaque “local AI does not work” problem into a small set of testable layers.
Once the connection is stable, Ollama can behave like another provider in a multi-provider workspace rather than a separate special-purpose chat environment.