Metadata-Version: 2.5
Name: langchain-nuroute
Version: 0.1.1
Summary: LangChain chat model for the NuRoute inference gateway
Project-URL: Homepage, https://github.com/NuRoute-ai/langchain-nuroute
Project-URL: Repository, https://github.com/NuRoute-ai/langchain-nuroute
Project-URL: Issues, https://github.com/NuRoute-ai/langchain-nuroute/issues
Project-URL: Documentation, https://nuroute.ai/docs
License: MIT
Requires-Python: >=3.9
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: nuroute>=0.1.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Description-Content-Type: text/markdown

# langchain-nuroute

A [LangChain](https://python.langchain.com) chat model for [NuRoute](https://nuroute.ai) — 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`](../sdk-python) 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

```bash
pip install langchain-nuroute
```

Requires **Python 3.9+**.

## Quick start

```python
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

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

## Forcing a provider or model

```python
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:

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

## Documentation

Full SDK documentation: [nuroute.ai/docs](https://nuroute.ai/docs)

## License

MIT
