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
num_predict=1024, # max tokens to generate in one reply
)
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 forchat.
License
MIT
Metadata
Release files for ollama-langchain-client 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ollama_langchain_client-0.1.2.tar.gz | 4.4 kB | Without provenance | Details for ollama_langchain_client-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ollama_langchain_client-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for ollama_langchain_client-0.1.2-py3-none-any.whl |
Total release size: 9.4 kB
Release files / ollama_langchain_client-0.1.2.tar.gz
| Download URL | ollama_langchain_client-0.1.2.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f009ddb3e564b86618cf1c05418cf0a849e5d2a8bdb67ccfcc270d47f02e8769
|
|
BLAKE2b-256 checksum How to use checksums |
cebca5fd90876767e09a321fba5da70ab034f8066c8647f958a50911558e4948
|
| 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.2-py3-none-any.whl
| Download URL | ollama_langchain_client-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9762ebc2ed42e7dacfb0f8bad50d3a91337fc117db308c93aa27084bb83453f7
|
|
BLAKE2b-256 checksum How to use checksums |
ea28fd27dfe17324aea3091566f35694b8f1ee3b4ed712a7ef9a0f5a51fed3c1
|
| 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.2
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.