Integrations

Ollama’s value is often as a local model backend for other tools. This chapter covers sibling courses on this site, editors, and the Docker hostname mistake everyone hits once.


Which interface to expose

The other side expectsYou provide
Hard-coded OpenAI SDK / “OpenAI compatible”http://localhost:11434/v1 and a name from ollama ls
An “Ollama” providerHost http://localhost:11434, native /api
Chat only, no protocol preferenceollama run or the official Python/JS libraries

The interactive menu and ollama launch can configure Claude Code, OpenClaw, VS Code, OpenCode, Codex, and more. See integrations and the CLI.


Dify: model provider

In Dify, add Ollama as a model provider. Point API Base at your daemon (http://localhost:11434 for local debugging—match Dify’s current form) and use names from ollama ls. Configure chat and embedding models separately so knowledge retrieval can follow the Embeddings path.

If Dify runs in Docker and Ollama is on the host, do not put localhost inside the container (that is the container itself). Use host.docker.internal in the next section.


LangChain

Two usual routes:

  1. langchain-ollama (ChatOllama / OllamaEmbeddings) on the native protocol.
  2. ChatOpenAI with base_url="http://localhost:11434/v1" and any placeholder api_key.

Agents: LangChain Quick Start. RAG: RAG. If your installed integration accepts ollama:gemma4-style provider strings, use whatever that package documents.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gemma4",
    base_url="http://localhost:11434/v1",
    api_key="ollama",
)

Hermes and OpenClaw

Self-hosted agents can treat Ollama as a local (or Cloud) backend without sending keys to a third-party chat vendor:

Launch tools in the menu and ollama launch write the URL and model the other app expects. If that still fails, curl /v1/chat/completions to separate “agent misconfigured” from “Ollama is not listening.”


Cursor: custom OpenAI-compatible base URL

In Cursor model settings, add an OpenAI compatible (or equivalent custom API) entry:

FieldValue
Base URLhttp://localhost:11434/v1 or http://localhost:11434/v1/
API KeyAny non-empty string, e.g. ollama
Modelgemma4 or a name you created

Start a chat locked to that model and confirm it is local (ollama ps should move). Context length follows Ollama defaults or Modelfile num_ctx—the compatibility layer does not magically unlock 128k.


Docker networking: host.docker.internal

LayoutBase URL inside the app container
App container → Ollama on the hosthttp://host.docker.internal:11434
Same Compose network as Ollamahttp://ollama:11434 (service name)
Linux without that DNS name--add-host=host.docker.internal:host-gateway on the app container

Anti-pattern: http://localhost:11434 from a Dify / LangServe container. That hits the container’s own port 11434, not your GPU box.

When Ollama itself is in Docker:

docker run -d --name ollama -v ollama:/root/.ollama -p 11434:11434 ollama/ollama

GPU / ROCm flags: Installation and Docker. To share on a LAN, set OLLAMA_HOST and use a firewall—do not publish 11434 to the public internet bare.


Other editors and agents

VS Code, JetBrains, Continue, Cline, Zed, and similar tools usually accept an OpenAI-compatible URL. Same rules: v1 base + real model name + pull first. ollama launch vscode reduces hand-editing.

How Library tags relate to HF pages and GGUF names: Hugging Face.


Integration checklist

  1. On the host: curl http://localhost:11434/api/tags lists models
  2. Compatibility: POST /v1/chat/completions returns choices[0].message
  3. From the app container: curl http://host.docker.internal:11434/api/tags
  4. Names in Dify / Cursor / the agent match ollama ls exactly

Next steps

评论