LangChain integration for Concentrate.ai — a unified LLM gateway with the OpenAI Responses API.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_concentrate-0.1.0.tar.gz.
File metadata
- Download URL: langchain_concentrate-0.1.0.tar.gz
- Upload date:
- Size: 167.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e54a75d5377869cc82e946b026911ef66682f7c8f302b312dd070c37ff7019fe
|
|
| MD5 |
552f497196f42a79dfaddbab70bb4819
|
|
| BLAKE2b-256 |
8bef939a5655c8eefa4f01d6a2bf96edee8a1188f58bdc8a8b0dd099369ccd68
|
Provenance
The following attestation bundles were made for langchain_concentrate-0.1.0.tar.gz:
Publisher:
release.yml on concentrate-ai/langchain-concentrate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_concentrate-0.1.0.tar.gz -
Subject digest:
e54a75d5377869cc82e946b026911ef66682f7c8f302b312dd070c37ff7019fe - Sigstore transparency entry: 2087455314
- Sigstore integration time:
-
Permalink:
concentrate-ai/langchain-concentrate@765167839301f02c517796895a0e337ab993297f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/concentrate-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@765167839301f02c517796895a0e337ab993297f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file langchain_concentrate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_concentrate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e29660452d6c8ee5239e32887717cc0d72553835f3c965c85a1b94ea8ad42f18
|
|
| MD5 |
33f607f88241bd427b85ecbdbb6cc8a9
|
|
| BLAKE2b-256 |
5b1edfb7eb47a48b88e3f2bb7bc04a4734784f8187a81aa39033bf37a62bcd42
|
Provenance
The following attestation bundles were made for langchain_concentrate-0.1.0-py3-none-any.whl:
Publisher:
release.yml on concentrate-ai/langchain-concentrate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_concentrate-0.1.0-py3-none-any.whl -
Subject digest:
e29660452d6c8ee5239e32887717cc0d72553835f3c965c85a1b94ea8ad42f18 - Sigstore transparency entry: 2087455450
- Sigstore integration time:
-
Permalink:
concentrate-ai/langchain-concentrate@765167839301f02c517796895a0e337ab993297f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/concentrate-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@765167839301f02c517796895a0e337ab993297f -
Trigger Event:
workflow_dispatch
-
Statement type: