Skip to main content

langchain-gradient

PyPI Downloads

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 for the full breaking-change list

Installation

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.
  3. Click on Create model access key, enter a name, and create the key.
  4. 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

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

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.

Download files

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

Source Distribution

langchain_gradient-1.0.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

langchain_gradient-1.0.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file langchain_gradient-1.0.0.tar.gz.

File metadata

  • Download URL: langchain_gradient-1.0.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.2

File hashes

Hashes for langchain_gradient-1.0.0.tar.gz
Algorithm Hash digest
SHA256 68caeb32ea753768fbae980fdc4b71cd8db275f3acef98e3829c61033d77dfad
MD5 42830c793724c6c8e098dcf5820f3b78
BLAKE2b-256 129d39e21a7217a1a92ee5b6879bf086c4059ca363af0a15c2af373bd20027fa

See more details on using hashes here.

File details

Details for the file langchain_gradient-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_gradient-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcc82fdf0f7e90d8a899f32b513fac7afed77ec69ecbbe5c61dea4386393e38b
MD5 f38a3cb8528cfa4ccfb5914ed98e9d02
BLAKE2b-256 b9033d468dddde1a636aee3562b1bf505f6e45ac7869ccb463f473f8e537cbfa

See more details on using hashes here.

Supported by

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