This SDK (
gradient) is deprecated and will be retired on August 15, 2026. Please migrate to the unified DigitalOcean Python SDK:pydo.Overview of official DigitalOcean libraries: https://docs.digitalocean.com/reference/libraries/
| From | To |
|---|---|
gradient |
pydo |
pip uninstall gradient
pip install pydo
# optional async extras
pip install "pydo[aio]"Gradient used several auth modes on one client. Map each to pydo:
| Use case | Gradient (Python) | Env var (Gradient) | pydo |
|---|---|---|---|
| DigitalOcean API / GenAI control plane | access_token= |
DIGITALOCEAN_ACCESS_TOKEN |
Client(token=...) or Client(api_key=...) with a DigitalOcean PAT — prefer DIGITALOCEAN_TOKEN |
| Serverless inference | model_access_key= |
GRADIENT_MODEL_ACCESS_KEY |
from pydo.inference import Client → pass the same Model Access Key (or a full-access PAT) as token / api_key |
| Agent inference | agent_access_key= + agent_endpoint= |
GRADIENT_AGENT_ACCESS_KEY + GRADIENT_AGENT_ENDPOINT |
Pass the agent access key as token / api_key and set agent_endpoint on the client |
Notes:
- The Model Access Key value does not change — only the constructor / env name.
- Limited-scope PATs return 401 on inference; use a full-access PAT or a Model Access Key.
- Update
.env, CI secrets, and runbooks accordingly.
Before
from gradient import Gradient
client = Gradient(model_access_key=os.environ["GRADIENT_MODEL_ACCESS_KEY"])After
from pydo.inference import Client
# Same Model Access Key value as GRADIENT_MODEL_ACCESS_KEY, or a full-access PAT
client = Client(api_key=os.environ["GRADIENT_MODEL_ACCESS_KEY"])
# equivalently:
# client = Client(token=os.environ["DIGITALOCEAN_TOKEN"]) # must be full-accessBefore
from gradient import Gradient
client = Gradient(access_token=os.environ["DIGITALOCEAN_ACCESS_TOKEN"])After
from pydo import Client
# Same PAT value as DIGITALOCEAN_ACCESS_TOKEN; preferred env name is DIGITALOCEAN_TOKEN
client = Client(token=os.environ["DIGITALOCEAN_TOKEN"])- Before:
from gradient import AsyncGradient - After:
from pydo.inference.aio import Clientorfrom pydo.aio import Client(preferasync with)
Chat, streaming, images, and model listing keep a similar OpenAI-style shape. Only the import and client constructor change.
# pydo inference
resp = client.chat.completions.create(
model="llama3.3-70b-instruct",
messages=[{"role": "user", "content": "Hello"}],
)| Capability | Gradient | pydo |
|---|---|---|
| Chat completions | client.chat.completions.create |
same via pydo.inference |
| Streaming | stream=True |
supported |
| Image generation | Gradient images APIs | client.images.generate |
| List models | Gradient models | client.models.list |
| Manage agents / GenAI | Gradient API client | top-level pydo.Client |
Rework error handling: Gradient Stainless APIError subclasses do not map 1:1 to pydo errors. Re-check retries and timeouts against the new client defaults.
- Confirm the app builds and runs with only
pydo. - Smoke-test non-streaming chat, streaming chat,
models.list, and images (if used). - Verify inference with a full-access PAT and, if applicable, a Model Access Key.
- Remove
gradientfrom lockfiles. - After cutover, remove unused Gradient env vars if you renamed them.
- Complete migration before August 15, 2026.