Metadata-Version: 2.5
Name: ollama-client
Version: 0.2.0
Summary: Lightweight CLI client for a remote Ollama server
Project-URL: Homepage, https://github.com/rhiza-fr/ollama-client
Project-URL: Repository, https://github.com/rhiza-fr/ollama-client
Author-email: Chris Kilner <chris@rhiza.fr>
License-Expression: MIT
License-File: LICENSE
Keywords: ai,chat,cli,llm,ollama,remote
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Requires-Dist: pyyaml>=6
Requires-Dist: rich>=13
Description-Content-Type: text/markdown

# ollama-client

A small command-line client for an [Ollama](https://ollama.com) server running on another machine.

It replaces the `ollama` command on machines that only need to *talk* to a server: same commands, same flags, same output. Install it on your laptop, point it at the machine with the GPU, and use it as you would use `ollama`.

```bash
uv tool install ollama-client
export OLLAMA_HOST=http://my-server:11434

ollama-client list
ollama-client run qwen3.5:4b "Why is the sky blue?"
```

## Why not install ollama?

The `ollama` download (about 1.9 GB) includes the full inference server: GPU runtimes and the model runner. On a machine that never runs models itself, none of that is used. `ollama-client` is a 30 KB pure-Python package.

- **Keep models in one place.** Models, GPU memory and the server process live on one machine; every laptop, WSL shell or CI runner uses the client.
- **Easy to install anywhere.** `uv tool install` or `pip install`, no sudo, no installer script, no background service.
- **Script-compatible.** Tables, size and time formats, and error messages follow the official client, so scripts that parse `ollama` output keep working. See [Compatibility](#compatibility-with-ollama) for the exceptions.

## Install

Requires Python 3.11 or later.

```bash
uv tool install ollama-client    # or: pip install ollama-client
```

## Connect to your server

Tell the client where the server is. The first of these that is set wins:

1. The `--host` (or `-H`) flag: `ollama-client -H http://192.168.1.10:11434 list`
2. `OLLAMA_CLIENT_HOST`: use this to point the client somewhere other than `OLLAMA_HOST`.
3. `OLLAMA_HOST`: the variable the official client uses. A server-side bind address such as `0.0.0.0` is read as `localhost`.
4. The config file `~/.config/ollama-client/config.toml`:

   ```toml
   [ollama]
   host = "http://192.168.1.10:11434"
   ```

5. The default, `http://localhost:11434`.

The `http://` prefix and the port are optional: `my-server` becomes `http://my-server:11434`.

## Usage

```
ollama-client COMMAND [flags]

  run       Chat with a model, or run a single prompt
  pull      Download a model to the server
  list, ls  List models on the server
  ps        List models loaded in memory
  stop      Unload a model from memory
  show      Show information about a model
  rm        Delete models from the server
  cp        Copy a model under a new name
  launch    Start a coding tool (Claude Code, Codex, ...) that uses the server
  signin    Sign in to ollama.com
  signout   Sign out of ollama.com
  help      Show help for a command (also: COMMAND --help)
```

### Chat and prompts

```bash
# Interactive chat; the conversation is kept until you type /clear or /bye
ollama-client run qwen3.5:4b

# Single prompt
ollama-client run qwen3.5:4b "Why is the sky blue?"
ollama-client run qwen3.5:4b "Summarise this." --system "You are a concise assistant."

# Piped input is placed before the prompt
cat notes.txt | ollama-client run qwen3.5:4b "Summarise this."

# Reasoning models: show the thinking (dimmed), or let the model think but hide it
ollama-client run qwen3.5:4b "What is 17 * 23?" --think
ollama-client run qwen3.5:4b "What is 17 * 23?" --think --hidethinking

# Timing and token statistics after the answer
ollama-client run qwen3.5:4b "Hello" --verbose
```

Other `run` flags: `--format json`, `--keepalive 10m` (how long the model stays loaded), `--nowordwrap`. In the chat, `/help` lists the commands; `/bye` or `Ctrl+D` exits; `Ctrl+C` stops a reply in progress.

### Embedding models

`run` on an embedding model prints the embedding vector as JSON.

```bash
ollama-client run embeddinggemma "hello world"
ollama-client run embeddinggemma "hello world" --dimensions 256   # shorter vector
```

Inputs longer than the model's context are truncated; add `--truncate=false` to get an error instead.

### Decision models

Decision models (such as `nimble`) don't write text: they answer questions about a piece of text with a probability. Give the text as the prompt or on stdin, and one or more `--ask` questions:

```bash
# Yes or no
ollama-client run nimble --ask "Is a refund being requested?" < ticket.txt

# Pick one label (an optional description follows =)
ollama-client run nimble --ask "Which team should handle this?" \
  --choice billing="Payments and refunds" \
  --choice technical="Software problems" < ticket.txt

# Place on a scale, lowest level first
ollama-client run nimble --ask "How urgent is this?" \
  --level Routine --level Soon --level Immediate < ticket.txt
```

Each `--choice` or `--level` belongs to the `--ask` before it. Add `--format json` for the full response with all probabilities.

### Manage models

```bash
ollama-client pull qwen3.5:4b
ollama-client list                    # all models
ollama-client list qwen               # names starting with "qwen"
ollama-client ps                      # loaded models, CPU/GPU split, context size
ollama-client stop qwen3.5:4b
ollama-client show qwen3.5:4b         # architecture, capabilities, parameters, license
ollama-client show qwen3.5:4b -v      # also all metadata and tensors
ollama-client show qwen3.5:4b --modelfile   # or --parameters, --template, --system, --license
ollama-client rm qwen3.5:4b qwen3.5:9b
ollama-client cp qwen3.5:4b my-qwen
```

### Launch a coding tool

`launch` configures a coding assistant to use models on your Ollama server, then starts it.

```bash
ollama-client launch                                   # pick the tool and model from a menu
ollama-client launch claude --model qwen3.5:4b         # start directly
ollama-client launch codex --config --model qwen3.5:4b # write the configuration only
ollama-client launch codex -- --sandbox workspace-write # pass arguments to the tool
```

| Name | Description | Configuration method |
|---|---|---|
| `claude` | Claude Code | Environment variables (`ANTHROPIC_BASE_URL`, model overrides) |
| `copilot` | Copilot CLI | Environment variables (`COPILOT_PROVIDER_BASE_URL`) |
| `codex` | Codex | `~/.codex/config.toml` (merged, not overwritten) |
| `hermes` | Hermes Agent | `~/.hermes/config.yaml` (merged, legacy `ollama` provider removed) |
| `opencode` | OpenCode | `OPENCODE_CONFIG_CONTENT` environment variable |
| `pi` | Pi | `~/.pi/agent/models.json` and `~/.pi/agent/settings.json` |
| `vscode` | VS Code | Launches `code` (no Ollama config; use the Ollama VS Code extension) |


Aliases: `copilot-cli` for `copilot`, `code` for `vscode`.

## Compatibility with ollama

Output is byte-for-byte the same as the official client's (checked against ollama 0.40.18), so scripts parsing it keep working:

- `list` and `ps` tables, including column padding
- `show` and `show -v` sections, including how long values wrap
- Sizes in SI units (`9.5 GB`, `1 MB`) and relative times (`About an hour ago`, `8 weeks ago`)
- `run`: the response on stdout followed by a blank line; the spinner and `--verbose` statistics on stderr
- Embedding vectors and decision answers
- Errors as `Error: ...` on stderr; `pull` ends with `success`

### Differences

- **Not included:** `serve` (this is only a client), `create` and `push`.
- **`run` flags not supported:** `--voice` (speech models), the hidden `--runner`, and image file paths in the prompt.
- **Decision models** answer `--ask` questions in a single run only; there is no interactive decision mode.
- **Chat commands:** only `/help`, `/clear` and `/bye`. The official `/save`, `/load`, `/show`, `/set`, `/unset` and `"""` multi-line input are not available.
- **`launch`** covers configuring and starting the tool. The official version adds a full-screen menu, capability checks, automatic installation of the tool and cloud models.
- **Spinners and the `pull` progress bar** look similar but not identical.

A single `run MODEL PROMPT` uses `/api/generate`; the interactive chat uses `/api/chat` and sends the whole conversation each turn, as the official client does.

## Dependencies

- [`httpx`](https://www.python-httpx.org/): HTTP client.
- [`rich`](https://github.com/Textualize/rich): live streaming text, spinners and the `pull` progress bar.
- [`pyyaml`](https://pyyaml.org/): used only by `launch hermes`, to update `~/.hermes/config.yaml` without losing the existing settings.

## Development

```bash
uv sync
uv run ollama-client --help
uv run pytest                     # unit tests, no server needed
uv run mypy src/ollama_client
uv run ruff check src/ollama_client
```

### Compatibility tests

The `compat` tests run both this client and the real `ollama` against a live server and compare the results. They need a running Ollama server (default `http://localhost:11434`), the `ollama` binary on `PATH`, and [`tmux`](https://github.com/tmux/tmux) for the interactive tests.

```bash
uv run pytest -m compat                                   # default model: rnj-1:latest
OLLAMA_COMPAT_MODEL=qwen3.5:4b uv run pytest -m compat    # another model
uv run pytest -m compat tests/test_compat.py::TestHelp    # flag checks only; needs just the ollama binary
```
