Skip to main content

ollama-langchain-client

A lightweight, reusable Python client for Ollama's OpenAI-compatible chat API, built on top of langchain-openai.

Point it at any Ollama server (local or remote) and chat with your models, optionally toggling chain-of-thought "thinking" for models that support it.

Installation

pip install ollama-langchain-client

Quick start

from ollama_langchain_client import OllamaClient

# Defaults to a local Ollama server
client = OllamaClient(model="gemma4:12b")

reply = client.chat("你好!")
print(reply)

Point at a remote server and control "thinking":

client = OllamaClient(
    model="gemma4:12b",
    base_url="http://your-server:11434/api/chat",
    api_key="ollama",
    temperature=0.0,
    think=False,   # disable chain-of-thought thinking
)

API

OllamaClient

Parameter Type Default Description
model str "gemma4:12b" Ollama model name.
base_url str "http://localhost:11434/api/chat" Ollama OpenAI-compatible endpoint.
api_key str "ollama" Auth token sent to Ollama.
temperature float 0.0 Sampling temperature.
think bool False Disable chain-of-thought thinking when False.
timeout float | None None Optional request timeout (seconds).
**kwargs — — Extra args forwarded to ChatOpenAI.

Methods:

  • chat(message, **kwargs) -> str — send a message, return the reply text.
  • invoke(message, **kwargs) -> str — alias for chat.

License

MIT

Metadata

Release files for ollama-langchain-client 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ollama-langchain-client 0.1.0
File Size Uploaded Provenance Actions
ollama_langchain_client-0.1.0.tar.gz 4.2 kB Without provenance Details for ollama_langchain_client-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ollama-langchain-client 0.1.0
File Interpreter ABI Platform Actions
ollama_langchain_client-0.1.0-py3-none-any.whl Python 3 none any Details for ollama_langchain_client-0.1.0-py3-none-any.whl

Total release size: 9.1 kB

Release files / ollama_langchain_client-0.1.0.tar.gz

Download URL ollama_langchain_client-0.1.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bd4ef6a73cc5cf1cc18ea1f56f6183f1fda520f510a586eb8acdc7b26a27323d
BLAKE2b-256 checksum
How to use checksums
169b3a4fd6401710ed873f9e71bf2c24ad34997d755eb9118b48740e7ed0d500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / ollama_langchain_client-0.1.0-py3-none-any.whl

Download URL ollama_langchain_client-0.1.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed6ac480732937076e733a6ad44c844a643dbc56d4195d411dc7ae9f2d9c2d1a
BLAKE2b-256 checksum
How to use checksums
834dd7ebadd4c025e8813d924bc89996ac69d9a88647c43e4fe06ba8415ef236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for ollama-langchain-client 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page