Skip to main content

langchain-nuroute

A LangChain chat model for NuRoute — a provider-agnostic LLM gateway that routes, monitors, and controls inference requests across OpenAI, Anthropic, Google, and more.

This talks to the gateway through the official aicp client rather than through ChatOpenAI's OpenAI-compatibility path, so NuRoute-specific behavior — the "auto" routing model, provider overrides, and NuRouteError — comes through unchanged instead of being flattened into OpenAI's response/error shapes.

Installation

pip install langchain-nuroute

Requires Python 3.9+.

Quick start

from langchain_nuroute import ChatNuRoute
from langchain_core.messages import HumanMessage

llm = ChatNuRoute(
    nuroute_api_key="aicp-...",
    nuroute_base_url="https://your-nuroute-gateway",
    model="auto",  # classifies the request and routes it — see nuroute.ai/docs for strategies
)

response = llm.invoke([HumanMessage(content="Hello!")])
print(response.content)

Streaming

for chunk in llm.stream([HumanMessage(content="Tell me a story")]):
    print(chunk.content, end="", flush=True)

Forcing a provider or model

llm = ChatNuRoute(
    nuroute_api_key="aicp-...",
    nuroute_base_url="https://your-nuroute-gateway",
    model="claude-sonnet-4-6",
    provider="anthropic",
    temperature=0.2,
    max_tokens=1024,
)

Usage and routing metadata

ChatResult.llm_output carries the model NuRoute actually routed to and the token usage for the call:

result = llm.generate([[HumanMessage(content="Hello!")]])
print(result.llm_output["model"], result.llm_output["usage"])

Documentation

Full SDK documentation: nuroute.ai/docs

License

MIT

Metadata

Release files for langchain-nuroute 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-nuroute 0.1.0
File Size Uploaded
langchain_nuroute-0.1.0.tar.gz 149.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-nuroute 0.1.0
File Interpreter ABI Platform
langchain_nuroute-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 152.9 kB

Release files / langchain_nuroute-0.1.0.tar.gz

Download URL langchain_nuroute-0.1.0.tar.gz
Size 149.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c1c09034e674ca91c4206ad4170d4f1c028f6fe8125e1615123b28056b306d4d
BLAKE2b-256 checksum
How to use checksums
5707ef46d93c07452ffc82597f9c32e5ee52e3f37eb60ba30b72324ac1bdf4b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / langchain_nuroute-0.1.0-py3-none-any.whl

Download URL langchain_nuroute-0.1.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
627090fd98c72b396a9a7b95e6de5f7089c4d3efe9c81755aa850b693bc8f040
BLAKE2b-256 checksum
How to use checksums
82dd956e416bde46ca6193c83a4267ba3f2b171f157c4bded03e5d8c72845b93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

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