langchain-concentrate
LangChain integration for Concentrate.ai — a unified LLM gateway that lets you access OpenAI, Anthropic, Google, DeepSeek and other providers through a single API, with governance, spend tracking, fallbacks and auto-routing.
Concentrate exposes an OpenAI Responses API–compatible endpoint at
https://api.concentrate.ai/v1, so this package is a thin subclass of
langchain-openai's ChatOpenAI that pins the base URL, forces the Responses
path, and reads its key from CONCENTRATE_API_KEY.
Install
pip install langchain-concentrate
# or
uv add langchain-concentrate
Quickstart
export CONCENTRATE_API_KEY="sk-cn-v1-..."
from langchain_concentrate import ChatConcentrate
model = ChatConcentrate(model="gpt-5.4")
print(model.invoke("Say hi in three words.").text)
Streaming
for chunk in model.stream("Count from 1 to 5."):
print(chunk.text, end="", flush=True)
Auto-routing
Pass model="auto" with a routing directive to let Concentrate pick a
provider based on your policy:
cheap = ChatConcentrate(
model="auto",
routing={"strategy": "min", "metric": "cost"},
)
cheap.invoke("What is 2 + 2?")
Tool calling & structured output
Because ChatConcentrate inherits from ChatOpenAI, bind_tools and
with_structured_output work out of the box for models that support them
downstream.
from pydantic import BaseModel
class Answer(BaseModel):
number: int
structured = ChatConcentrate(model="gpt-5.4").with_structured_output(Answer)
result = structured.invoke("What is 2 + 2?")
assert result.number == 4
Configuration
| Env var | Purpose | Default |
|---|---|---|
CONCENTRATE_API_KEY |
API key sent as Authorization: Bearer <key>. |
(required) |
CONCENTRATE_BASE_URL |
Override the API base URL. | https://api.concentrate.ai/v1 |
Any keyword accepted by ChatOpenAI — temperature, max_output_tokens,
timeout, default_headers, extra_body, model_kwargs, etc. — can be
passed through.
Development
uv sync --all-groups
make test # unit tests (no network)
make integration_tests # against real Concentrate, needs CONCENTRATE_API_KEY
License
MIT
Disclaimer
Portions of this package were generated with the help of an AI coding assistant. All code is human-reviewed.
Metadata
Release files for langchain-concentrate 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_concentrate-0.1.0.tar.gz | 167.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_concentrate-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 173.4 kB
Release files / langchain_concentrate-0.1.0.tar.gz
| Download URL | langchain_concentrate-0.1.0.tar.gz |
|---|---|
| Size | 167.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e54a75d5377869cc82e946b026911ef66682f7c8f302b312dd070c37ff7019fe
|
|
BLAKE2b-256 checksum How to use checksums |
8bef939a5655c8eefa4f01d6a2bf96edee8a1188f58bdc8a8b0dd099369ccd68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.
Transparency logRelease files / langchain_concentrate-0.1.0-py3-none-any.whl
| Download URL | langchain_concentrate-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e29660452d6c8ee5239e32887717cc0d72553835f3c965c85a1b94ea8ad42f18
|
|
BLAKE2b-256 checksum How to use checksums |
5b1edfb7eb47a48b88e3f2bb7bc04a4734784f8187a81aa39033bf37a62bcd42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.
Transparency log