Metadata-Version: 2.4
Name: tessera-langchain
Version: 0.1.0
Summary: Drop-in Tessera integration for LangChain. One line of config routes your existing ChatOpenAI / ChatAnthropic / ChatMistralAI / ChatGroq / ChatCohere through Tessera's auto-route + auto-cache + auto-compress + auto-batch proxy. Free tier: 60M tokens/mo. Production: 20% of measured savings.
Project-URL: Homepage, https://tesseraai.io
Project-URL: Documentation, https://tesseraai.io/dev
Project-URL: Repository, https://github.com/tessera-llm/tessera-langchain
Project-URL: Issues, https://github.com/tessera-llm/tessera-langchain/issues
Project-URL: Changelog, https://github.com/tessera-llm/tessera-langchain/blob/main/CHANGELOG.md
Project-URL: Main SDK, https://github.com/tessera-llm/tessera-sdk
Author-email: "Tessera (Fintechagency OÜ)" <contact@tesseraai.io>
License: Apache-2.0
Keywords: ai-cost,anthropic,claude,cohere,cost-optimization,gemini,gpt-4o,groq,langchain,langchain-integration,llm,llm-cost,llm-proxy,mistral,openai,tessera
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: pytest-mock>=3.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest-mock>=3.0; extra == 'test'
Requires-Dist: pytest>=7.0; extra == 'test'
Description-Content-Type: text/markdown

# tessera-langchain

[![PyPI version](https://img.shields.io/pypi/v/tessera-langchain.svg)](https://pypi.org/project/tessera-langchain/) [![Python](https://img.shields.io/pypi/pyversions/tessera-langchain.svg)](https://pypi.org/project/tessera-langchain/)

**Drop-in cost optimization for LangChain ChatModels.** One line of config in your existing `ChatOpenAI` / `ChatAnthropic` / `ChatMistralAI` / `ChatGroq` / `ChatCohere` constructor routes your traffic through the [Tessera](https://tesseraai.io) proxy — auto-route, exact + provider-prompt-cache hits, per-role compression, output-length ceiling, batch arbitrage. Free Dev tier: **60M tokens/month, no card**. Production: **20% of measured savings, $0 if we save you nothing**.

Companion package to [`tessera-llm-proxy`](https://pypi.org/project/tessera-llm-proxy/) — same proxy, LangChain-shaped API.

## Install

```bash
pip install tessera-langchain
```

## Quickstart

```python
from langchain_openai import ChatOpenAI
from tessera_langchain import tessera_openai_config

llm = ChatOpenAI(
    model="gpt-4o",
    openai_api_key="sk-...",                      # your OpenAI key, unchanged
    **tessera_openai_config(api_key="tsr_..."),   # one line, routes through Tessera
)

# Existing LangChain code (agents, chains, tools, streaming) runs unchanged.
response = llm.invoke("Summarize a Kubernetes operator architecture in 3 bullets.")
```

Same pattern for the other providers — `tessera_anthropic_config`, `tessera_mistral_config`, `tessera_groq_config`, `tessera_cohere_config`.

Or wrap an existing instance:

```python
from tessera_langchain import wrap_openai

llm = wrap_openai(my_existing_ChatOpenAI, tessera_api_key="tsr_...")
```

## Free key

Get a free API key (60M tokens/mo, no card) at **[tesseraai.io/dev](https://tesseraai.io/dev)** — sign-up takes ~30 seconds and returns an instant `tsr_…` key plus magic-link dashboard access.

## Documentation

Full README with worked-numbers example ($24k → $9.4k OpenAI bill cut), mechanic table, FAQ, and architecture notes:

→ **[github.com/tessera-llm/tessera-langchain](https://github.com/tessera-llm/tessera-langchain)**

Tessera platform:

→ **[tesseraai.io](https://tesseraai.io)**

## License

Apache-2.0. The SDK is open source; the optimization proxy at `api.tesseraai.io` is closed. Wire format is open; mechanic implementations are not.
