Skip to main content

langchain-concentrate

PyPI version

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 ChatOpenAItemperature, 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_concentrate-0.1.0.tar.gz (167.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_concentrate-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

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

Hashes for langchain_concentrate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e54a75d5377869cc82e946b026911ef66682f7c8f302b312dd070c37ff7019fe
MD5 552f497196f42a79dfaddbab70bb4819
BLAKE2b-256 8bef939a5655c8eefa4f01d6a2bf96edee8a1188f58bdc8a8b0dd099369ccd68

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_concentrate-0.1.0.tar.gz:

Publisher: release.yml on concentrate-ai/langchain-concentrate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_concentrate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_concentrate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e29660452d6c8ee5239e32887717cc0d72553835f3c965c85a1b94ea8ad42f18
MD5 33f607f88241bd427b85ecbdbb6cc8a9
BLAKE2b-256 5b1edfb7eb47a48b88e3f2bb7bc04a4734784f8187a81aa39033bf37a62bcd42

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page