Run a Local LLM with Ollama: Install and API

Vladimir Lomtev•
Run a Local LLM with Ollama: Install and API

To launch a local LLM through Ollama, install the app, download a local version of the model, and verify the response through the terminal or API. For the first run, use a small model and a short prompt: this makes it easier to separate installation issues from insufficient memory. After that, check GPU usage, quality on your own task, and the app’s access to the server.

Prepared by Vladimir Lomtev’s AI Studio on November 14, 2026, for developers and IT professionals starting local deployment. The commands are based on the Ollama documentation; no independent hardware testing was performed for this material. The example uses the text model Qwen2.5 1.5B as a compact training artifact, not as a recommendation for the best business model. Training and a high-load cluster are not covered in this guide.

Contents

What to prepare before installation

Ollama manages model downloads and execution and provides a programmatic interface. You can start with a chat in the terminal, then connect the same server to an application. Local execution means the model’s computations run on your computer or server; downloading the model files themselves initially requires access to the source.

In the current Ollama ecosystem, cloud options are also available, so the word Ollama alone does not prove that the chosen route is local. Before working with internal documents, verify the specific model, API address, and network requests. The official quickstart describes local and cloud usage separately.

Note the operating system, RAM amount, available VRAM, free disk space, and whether a suitable GPU is present. The model file size is only part of the requirement. Context, intermediate data, and parallel requests increase resource usage. Do not start with the largest available model size: the first successful response should verify the installation itself.

How to choose a model for the first run

The training example uses the existing tag qwen2.5:1.5b in the Ollama catalog. Its purpose is to provide a compact, easy-to-follow path. In production, choose the model again based on quality, license, size, and support for the required features.

Do not choose based only on the parameter count. For field extraction, accuracy and response format matter; for a knowledge base, handling provided context matters; for an agent, tool support and stable multi-step execution matter. The required capability should be tested on the specific model variant, not the family name.

It helps to prepare a few allowed examples first: a simple question, text with a missing field, an ambiguous request, and a prompt with an explicit instruction not to invent data. This set does not replace full acceptance testing, but it helps catch obvious mismatches before integration.

Installation on Windows, macOS, and Linux

On Windows and macOS, start with the official Ollama download page and the installer for your system. After installation, open the app and a new terminal. On Linux, use the project’s current instructions: the installation and service setup method depends on the environment.

For Linux, you can first download the official script to a file and read it instead of executing it immediately from the network:

curl -fsSL https://ollama.com/install.sh -o ollama-install.sh
less ollama-install.sh
sh ollama-install.sh

The last command installs the software and may request system privileges. Run it only in the intended environment. In a closed network environment, installation through the external network is not suitable: there you need a prebuilt release with dependencies.

Check that the command is available:

ollama --version

If the command is not found, restart the terminal and check whether installation completed. A PATH error is different from a server error: in the first case, the system cannot find the program; in the second, the client is found but cannot connect to the execution process.

Download and first chat

Download the training model and start a chat:

ollama pull qwen2.5:1.5b
ollama run qwen2.5:1.5b

Enter a short prompt, for example: “Explain in one sentence what local inference is.” The initial launch may include loading the model into memory. To evaluate normal response behavior, send the next prompt after the first completion.

You can separately view models downloaded to disk and instances running in memory:

ollama list
ollama ps

These are different checks. A model appearing in the file list does not mean it is currently occupying GPU memory. Conversely, ending a chat does not necessarily free all resources immediately: retention behavior is controlled by server and request settings.

If the client says the server is unavailable, first start the installed app or the corresponding service. For a manual foreground launch, use ollama serve; do not start a second instance on a port that is already in use.

Your first request to the local API

The standard local Ollama server uses the address http://localhost:11434. The next example sends a request to it, explicitly disables streaming, and limits the training generation:

curl http://localhost:11434/api/generate \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "qwen2.5:1.5b",
    "prompt": "Explain local inference in one sentence.",
    "stream": false,
    "options": {"temperature": 0, "num_predict": 80}
  }'

This syntax is intended for shells that use standard single quotes, such as Bash. In PowerShell, use curl.exe with escaping that matches your version, or use the Python example below. Do not mix rules from different shells when diagnosing the API.

The fields and time units are described in the Generate API documentation. Check not only the HTTP status but also the response content. Generation may stop at the length limit; for data extraction, that can leave the structure incomplete.

Connect from Python without extra libraries

Save the code in local_ollama.py. It uses the standard library, sets a timeout, and disables proxy use from environment variables for the local connection:

import json
from urllib.request import Request, ProxyHandler, build_opener

payload = {
    "model": "qwen2.5:1.5b",
    "prompt": "From the text 'We need 12 filters,' name only the quantity.",
    "stream": False,
    "options": {"temperature": 0, "num_predict": 40},
}
request = Request(
    "http://127.0.0.1:11434/api/generate",
    data=json.dumps(payload, ensure_ascii=False).encode("utf-8"),
    headers={"Content-Type": "application/json"},
    method="POST",
)
opener = build_opener(ProxyHandler({}))
with opener.open(request, timeout=120) as response:
    result = json.load(response)
print(result["response"])
print("Completion reason:", result.get("done_reason"))

Run: python3 local_ollama.py, and on Windows, with the appropriate installation — py local_ollama.py. In the example, 120 is the chosen client timeout in seconds, not a promise of speed. If the task exceeds it, identify the cause before increasing it automatically.

For production field extraction, a simple text response is not enough. You need a data contract, type validation, and missing-value handling. A separate Ollama instruction and JSON Schema shows that next step.

How to check GPU usage

Start with ollama ps and the server logs. In addition, use the accelerator vendor's monitoring tool; for NVIDIA, nvidia-smi is often used. Record memory usage and activity during the request, not just before it.

Full or partial execution on CPU does not necessarily mean something is broken. It may be related to available memory or the selected backend. What matters is whether the actual path meets your latency and capacity requirements.

Check compatibility on the official Ollama hardware support page. Do not assume requirements from another GPU just because the VRAM capacity matches. The driver, accelerator architecture, and operating system are also part of the launch conditions.

Context, model retention, and concurrent requests

Context includes the system prompt, history, and current data. If the application sends the entire large archive every time, increased latency may be expected. First, reduce the input to only what is needed and check whether the quality holds.

The keep_alive setting controls how long the model stays loaded after a request; it does not store finished user replies and does not replace the application's chat history. The value should be chosen based on request frequency and other processes using memory. The parameters are described in the Ollama FAQ.

Do not open dozens of concurrent requests just because the client library allows it. The server may queue them, and memory for active sequences will depend on the settings. For multiple users, run a separate load test.

How to give another application access

If the application runs on the same computer, start with the loopback address. If it is inside a container, localhost inside the container points to the container itself, not necessarily to the Ollama host. The connection setup must be configured explicitly.

For remote access, first define the trust boundary. Do not simply expose the inference service to the internet. Use an approved private network or a secure gateway with authentication, rate limits, and access logging. Do not change the listening address to all interfaces as a random “fix” for a network error.

If you need a shared team chat, read the article on LiteLLM and Open WebUI.

First-run errors

Symptom What to check Next step
Command not found The installation and PATH Open a new terminal and check where the program is installed
Server unavailable The application, service, port Check the process; do not start a duplicate on the same port
Model not found The exact tag and download Check the catalog and ollama list
Not enough memory The model size, context, other processes Start with a smaller model and one short request
First response is slow Loading into memory and input processing Compare the first-request and repeat-request metrics
JSON is not readable Streaming mode and output length For a tutorial request, set stream: false, check the stop reason

Do not treat every symptom by reinstalling. Keep the error message, version, model tag, and minimal request. For latency issues, there is a separate analysis of Ollama's slow first response.

First-run acceptance checklist

  • The Ollama command is available and the version has been recorded.
  • The exact tag of the selected local model is specified.
  • A short request completes in the terminal and through the API.
  • The connection address matches the expected machine.
  • CPU and GPU placement has been verified in practice.
  • The model responds acceptably on allowed working examples.
  • Errors and timeouts are handled by the application.
  • The service is available only to authorized clients.

Copy this list into the launch log and add the date, version, and result for each item next to it. It serves as a reproducible installation check, but it does not confirm readiness for large-scale production use or for processing any type of data.

The mechanisms behind the server settings are covered in the guide to inference engines and acceleration. Before choosing hardware, it is useful to go through the comparison of self-hosted inference and API.

Frequently asked questions

Do I need an API key for local Ollama?

For a standard request to the local server in this example, no key is used. For cloud services and a secured corporate gateway, the conditions are different; check the specific route.

Can I run a model without a GPU?

For supported models, a CPU path is possible, but you need to verify speed and available memory on your own hardware. A small tutorial run and a multi-user service have different requirements.

Can You Work Without the Internet?

After the programs, model, and dependencies are prepared locally, the local route can run without an external network. Full isolation must be confirmed separately, including the interface, updates, and additional tools.

Is Installation Enough for a Corporate Rollout?

No. You also need access, quality evaluation, load limits, observability, and an operations owner. The first answer checks only one small part of the system.

How Vladimir Lomtev’s AI Studio Helps Launch a Local Model

Vladimir Lomtev’s AI Studio can connect LLM deployment with data preparation, quality checks, and workflow integration. For a first launch, that means choosing the task, confirming a permissible deployment option, and connecting the model to the right system with agreed testing criteria.

Start with one process: what data comes in, what should come out, and who approves the result. Discuss the Task.

What to Do After the First Response

Document the working versions, model, parameters, and the minimum prompt. Then test quality on your own data and only after that increase context and load. If you need support for multiple users or complex scheduling, compare Ollama with server-side engines under the same conditions.

Request an audit

Share your contact details and we will follow up.

← All articles

Comments (0)

Loading comments…

Leave a comment
No registration required

Book a strategy call
for agentic operations

Tell us which workflow you want to improve. We will map feasibility, risks, and the fastest MVP path.

By submitting, you agree to our privacy policy

Contacts

Global Operations

Serving U.S. clients remotely
with private cloud and on-prem options

Strategy calls by request

We respond after reviewing your workflow context.

info@agentsunrise.pro

For partnership inquiries

Have a proposal?

Write to us in messengers

© 2026 AgentSunrise