CodeVetter · Repo Unpack · Feature catalog
ollama/ollama
User-facing surface = CLI subcommands + REST endpoints + OpenAI/Anthropic compat shims + a desktop chat app. Features cover the full model lifecycle (pull/create/push/copy/show/list/ps/delete), inference (generate/chat/embed with streaming NDJSON, thinking, tools, vision/audio, structured output, logprobs), cloud remote inference on ollama.com, experimental web search/fetch, and Codex Desktop integration via a loopback proxy.
- CLI commands: create, show, run, stop, serve (alias start), pull, push, signin/login, signout/logout, list, ps, cp, rm; hidden commands `runner` (MLX runner entrypoint) and `gpu-discover`
- Native API endpoints: /api/generate, /api/chat, /api/embed, /api/embeddings, /api/pull, /api/push, /api/tags (GET+HEAD), /api/show, /api/delete, /api/create, /api/blobs/:digest (POST+HEAD), /api/copy, /api/ps, /api/me, /api/signout, /api/version, /api/status
- OpenAI-compatible endpoints /v1/chat/completions, /v1/completions, /v1/embeddings, /v1/models(+/:model), /v1/responses(+ /compact), /v1/audio/transcriptions are middleware translators over the native handlers
- Anthropic compatibility is provided by POST /v1/messages -> middleware.AnthropicMessagesMiddleware -> ChatHandler
- `ollama create` supports two paths: classic Modelfile+API (parser.ParseFile -> CreateRequest -> blob upload -> /api/create) and in-process safetensors import with --quantize/--draft-quantize/--force when the server is local (OLLAMA_CREATE_REMOTE forces remote)
- Chat features include thinking control (think bool or level; --think/--hidethinking flags), tool calling via api.Tools parsed by model parsers, vision/audio inputs (ImageData, MediaKind), and shift/truncate context management options
- Structured output: GenerateRequest.Format accepts a JSON schema which is passed to llama-server's json_schema field; a built-in BNF grammarJSON exists for generic JSON mode
- Cloud/remote models: models whose Config has RemoteHost+RemoteModel are proxied by ChatHandler to remoteURL via api.NewClient, gated by envconfig.Remotes() allowlist and OLLAMA_NO_CLOUD; :cloud model refs take cloudPassthroughMiddleware on /v1 routes (inferred)
- Experimental endpoints: POST /api/experimental/web_search, /api/experimental/web_fetch, GET /api/experimental/model-recommendations served from a stale-while-revalidate modelCaches.recommendations
- A loopback-only Codex Desktop reverse proxy is mounted at /api/codex/* (proxy.CodexDesktopPathPrefix) to route between native Ollama models and Codex upstreams, with request logging via writeActivity
- Model auth uses an ed25519 keypair at ~/.ollama/id_ed25519 generated on serve start (initializeKeypair); registry challenge-response tokens are obtained via signed nonce requests (getAuthorizationToken)
- Interactive UX: bare `ollama` launches a Bubbletea TUI (runInteractiveTUI + welcome flow via cmd/launch + cmd/tui); `ollama run` without prompt enters readline-based interactive session; selectors/sign-in/upgrade prompts are injected as launch.Default* hooks
- Separate `bench` main package under cmd/bench provides a benchmarking CLI hitting the API (used by CI bench step)