This release is a pre-release and may not be stable for production use.
grad-sdk (Python)
The Python SDK for the Gradiated training platform: push datasets, preview and launch managed fine-tuning runs, evaluate models, download PEFT adapters and deploy them on Gradiated Cloud.
- Python 3.11+, one dependency (
httpx); a blockingGradclient (from asyncio, call it viaasyncio.to_thread). - Typed objects with a
.rawescape hatch,py.typed, typed errors, retries with backoff. - Works against Gradiated Cloud or a self-hosted
grad-server.
pip install grad-sdk
export GRADIATED_API_KEY=grad_...
# Self-hosted server: export GRADIATED_BASE_URL=http://localhost:8787
Quickstart
from grad import Grad
from grad.recipes import SFTRecipe
client = Grad() # reads GRADIATED_API_KEY and GRADIATED_BASE_URL
dataset = client.datasets.push("sql-quickstart", [
{"messages": [
{"role": "user", "content": "Count active users from yesterday."},
{"role": "assistant", "content": "SELECT count(*) FROM users WHERE active_at >= current_date - 1;"},
]},
{"messages": [
{"role": "user", "content": "Total revenue by plan this month."},
{"role": "assistant", "content": "SELECT plan, sum(amount_usd) FROM invoices GROUP BY plan;"},
]},
])
recipe = SFTRecipe(model="qwen/qwen3-8b")
# $0 preview: resolved defaults, warnings, tokens and cost
print(client.runs.plan(dataset=dataset, name="sql-helper", recipe=recipe))
run = client.runs.create(dataset=dataset, name="sql-helper", recipe=recipe, max_cost_usd=5).wait()
print(run.status, run.artifact)
# Self-hosted: download the PEFT LoRA and serve it with vLLM or SGLang.
# Gradiated Cloud: run.deploy() serves it behind a stable name.
run.artifact.download("./sql-helper-bundle.grad.tar.gz", format="bundle")
run.artifact.download("./sql-helper") (the default format="peft") extracts a verified PEFT
directory (adapter_config.json + adapter_model.safetensors) that vllm serve <base> --enable-lora --lora-modules sql-helper=./sql-helper loads directly.
Configuration
Every SDK and the CLI resolve configuration the same way (highest first):
- explicit arguments:
Grad(api_key=..., base_url=...); - the selected profile:
Grad(profile=...)orGRADIATED_PROFILE(e.g.localaftergrad local up); GRADIATED_API_KEY/GRADIATED_BASE_URL;- the
defaultprofile in$XDG_CONFIG_HOME/gradiated/config.json(written bygrad login); https://api.gradiated.com.
A key saved in a profile is only sent to that profile's base URL, and a selected profile that
doesn't exist is an error. Without a key for a non-loopback server, Grad() raises
GradConfigError before sending anything (api_key="" talks to a server without
authentication). A trailing /v1 on the base URL is dropped with a warning. Also: timeout=
(per request), max_retries= (default 2).
Errors
Every error subclasses grad.GradError. HTTP errors are grad.GradAPIError subclasses carrying
status, code, detail, request_id, the method and URL: AuthenticationError (401),
PermissionDeniedError (403), NotFoundError (404), ConflictError (409), ValidationError
(422, with field errors), RateLimitError (429), DeployUnavailableError and
InferenceUnavailableError (501), ServerError (5xx). Network failures raise
APIConnectionError / APITimeoutError; wait() raises RunFailedError (code run_failed,
run_cancelled or run_stopped_budget: anything but completed), EvalFailedError,
ImportFailedError or WaitTimeoutError; a list endpoint that repeats its cursor raises
PaginationLoopError instead of looping. Features documented for later waves raise
NotAvailableInV0Error with an alternative.
Continued training and idempotent calls
from grad import Grad
from grad.recipes import DPORecipe, SFTRecipe
client = Grad()
sft = client.runs.create(dataset="sql-sft", name="sql-helper", recipe=SFTRecipe()).wait()
dpo = client.runs.create(dataset="sql-prefs", name="sql-helper", recipe=DPORecipe(model=sft.artifact),
idempotency_key="sql-helper-dpo-1").wait()
runs.create, evals.create and deploy send a fresh Idempotency-Key per call (reused by
its retries); pass idempotency_key= to make a retry from another process return the first call's
result instead of starting a second run.
Development
PYTHONPATH=sdks/python python3 -m unittest discover -s sdks/python/tests
Unit tests use a scripted fake httpx transport and the shared wire fixtures in tests/fixtures/wire.
test_live.py runs these snippets against tests/harness/stack.ts; it skips unless
server/api/node_modules exists (pnpm -C server/api install --frozen-lockfile), and the Cloud
deploy flow also needs GRAD_TRAINER_PYTHON (a Python with torch, transformers and peft). The
transport in grad/_generated/client.py is generated from spec/openapi.yaml by
node scripts/generate-sdks.mjs.
Metadata
Release files for grad-sdk 0.2.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| grad_sdk-0.2.0a1.tar.gz | 134.0 kB | With provenance | Details for grad_sdk-0.2.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grad_sdk-0.2.0a1-py3-none-any.whl | Python 3 | none | any | Details for grad_sdk-0.2.0a1-py3-none-any.whl |
Total release size: 232.0 kB
Release files / grad_sdk-0.2.0a1.tar.gz
| Download URL | grad_sdk-0.2.0a1.tar.gz |
|---|---|
| Size | 134.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a65bc014cf2ccb212dc87edddf23566fd33628fc2c2f12db8035e2ea495ac42
|
|
BLAKE2b-256 checksum How to use checksums |
a63da852dcd7be12a9a69650bb6674c4a2db9911f814cbdf5e8e8c93dba9ff58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / grad_sdk-0.2.0a1-py3-none-any.whl
| Download URL | grad_sdk-0.2.0a1-py3-none-any.whl |
|---|---|
| Size | 98.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e9ca6604e2c0007b066f16599143ab90d915b54fa2af91308bb8990803854bc
|
|
BLAKE2b-256 checksum How to use checksums |
d971811c2374cdaf0b51b84de38b16cc982d21e093b4734408e6c82fcbf116d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for grad-sdk 0.2.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for grad_sdk-0.2.0a1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.