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.
num_predict int | None None Max tokens per reply (Ollama num_predict).
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.1

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.1
File Size Uploaded Provenance Actions
ollama_langchain_client-0.1.1.tar.gz 4.4 kB Without provenance Details for ollama_langchain_client-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 9.4 kB

Release files / ollama_langchain_client-0.1.1.tar.gz

Download URL ollama_langchain_client-0.1.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
331a52108e82e5084b97634a3fa2fae1b2b1a61eec80c7ae8eb4578f8446ba9b
BLAKE2b-256 checksum
How to use checksums
1439d2ad892d1273529621609af94d0ece48448c8e51b6d9785589fd801cf2b7
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.1-py3-none-any.whl

Download URL ollama_langchain_client-0.1.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79a61b69d38cd6706fddfb177346bc6c16a7846212036d0dee772460f836be47
BLAKE2b-256 checksum
How to use checksums
5cf0791112ce159fc7a25f97f9c0f278cd251a8572b7e5dc9ebcf875984fbde2
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.1

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