Metadata-Version: 2.4
Name: langchain-gradient
Version: 1.0.0
Summary: An integration package connecting Digitalocean and LangChain
License: MIT
License-File: LICENSE
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: langchain-core (>=0.3.81,<2.0.0)
Requires-Dist: pydo (>=0.39.0,<0.40.0)
Requires-Dist: python-digitalocean (>=1.17.0,<2.0.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: typing_extensions (>=4.0.0,<5.0.0)
Project-URL: Repository, https://github.com/digitalocean/langchain-gradient
Project-URL: Release Notes, https://github.com/digitalocean/langchain-gradient/releases/tag/v1.0.0
Project-URL: Source Code, https://github.com/digitalocean/langchain-gradient
Description-Content-Type: text/markdown

# langchain-gradient  
[![PyPI Downloads](https://static.pepy.tech/badge/langchain-gradient)](https://pepy.tech/projects/langchain-gradient)

This package contains the LangChain integration with DigitalOcean Gradient Serverless Inference.

## Migrating to 1.0.0

1.0.0 replaces the deprecated `gradient` SDK with `pydo` (Gradient SDK retires 2026-08-15).

- Reinstall so you pick up `pydo`: `pip install -U "langchain-gradient>=1.0.0"`
- Exception types now come from azure-core/pydo (not `gradient.*`)
- `timeout` must be a positive int (default `120`); it is an HTTP connect/read idle timeout, not a total generation budget
- See [CHANGELOG](CHANGELOG.md#100---2026-08-14) for the full breaking-change list

## Installation

```bash
pip install -U langchain-gradient
```

And you should configure credentials by setting the `DIGITALOCEAN_INFERENCE_KEY` environment variable:

1. Log in to the DigitalOcean Cloud console
2. Go to the **Gradient Platform** and navigate to **Serverless Inference**.
2. Click on **Create model access key**, enter a name, and create the key.
3. Use the generated key as your `DIGITALOCEAN_INFERENCE_KEY`:   


Create .env file with your access key:  
```DIGITALOCEAN_INFERENCE_KEY=your_access_key_here```

## Chat Models

`ChatGradient` class exposes chat models from langchain-gradient.

### Invoke

```python
import os
from dotenv import load_dotenv
from langchain_gradient import ChatGradient

load_dotenv()

llm = ChatGradient(
    model="llama3.3-70b-instruct",
    api_key=os.getenv("DIGITALOCEAN_INFERENCE_KEY")
)

result = llm.invoke("What is the capital of France?.")
print(result)
```

### Stream

```python
import os
from dotenv import load_dotenv
from langchain_gradient import ChatGradient

load_dotenv()

llm = ChatGradient(
    model="llama3.3-70b-instruct",
    api_key=os.getenv("DIGITALOCEAN_INFERENCE_KEY")
)

for chunk in llm.stream("Tell me what happened to the Dinosaurs?"):
    print(chunk.content, end="", flush=True)
```

More features coming soon.

