netgreener_sdk
Python SDK for NetGreener — the AI developer agent and runtime control layer for resource, cost, and environmental impact.
Integrate NetGreener into your own tools and pipelines: authenticate, manage projects, upload run evidence, and access reports that link code and releases to verified CPU/GPU, cost, energy, carbon, and water impact.
Thin Python client for the NetGreener HTTP API (/api/v1). Its methods follow
the public service contracts, including project features, run evidence, energy
baselines, and report generation.
Install
From this repository (editable):
pip install -e .
Requires Python 3.10+ and requests.
Quick start
from netgreener_sdk import NetGreenerClient, APIError
client = NetGreenerClient()
client.login(email="you@example.com", password="…")
me = client.get_me()
print(me["email"])
# Project feature metadata (Parquet / path pointer)
row = client.post_project_feature_metadata(
1,
{"parquet_path": "/data/features.parquet", "feature_version": 1},
)
# Repo-aware project (git_url match order mirrors CLI)
project = client.get_or_create_project(
"My ML repo",
"/work/my-ml",
git_url="https://github.com/acme/my-ml.git",
)
# Report AI summary credit quote (Phase 8d)
quote = client.quote_report_ai_summary(
org_id=1,
payload={
"template": "sustainability",
"scope_type": "org",
"period_config": {
"primary": {"from": "2026-04-01", "to": "2026-04-30"},
"comparisons": [],
},
},
)
print(quote["total_credits"])
# Generate and download (Phase 8 SDK P2)
result = client.generate_report(
1,
{
"template": "sustainability",
"scope_type": "org",
"period_config": {
"primary": {"from": "2026-04-01", "to": "2026-04-30"},
"comparisons": [],
},
"output_format": "both",
},
)
report_id = result["report"]["report_id"]
pdf_bytes = client.download_report(1, report_id, format="pdf")
Base URL
Pass the API root including /api/v1, e.g. https://your-host/api/v1.
Auth
login(email, password); sets the bearer token on the client; response includesuser,access_token,expires_in.set_token(token); use an existing JWT.get_access_token(); current token orNone.get_me();GET /auth/me(requires valid token).
Feature metadata writes on the server require developer or admin; GET requires project access.
Projects & reports (Phase 3b)
| Method | HTTP |
|---|---|
get_projects |
GET /projects |
create_project |
POST /projects |
update_project |
PUT /projects/{id} |
get_or_create_project |
list + match by git_url → directory → name; create or sync |
quote_report_ai_summary |
POST /organizations/{org_id}/reports/ai-summary/quote |
preview_report / generate_report |
POST .../reports/preview / .../generate |
get_report_history / download_report |
GET .../history / .../{report_id}/download |
get_report_settings / update_report_settings |
schedule + cost assumptions |
run_scheduled_report_now |
POST .../reports/schedule/run-now |
Local analyze (--paths, analyze_local) stays in the netgreener CLI package, not the SDK.
Tests
From repo root:
python -m pytest tests -q
Publish (CI)
Same PyPI token as the CLI : Azure Library group Package_credential, secret PYPI_API_TOKEN, must allow upload to both netgreener and netgreener_sdk.
Different pipeline and tag (not the CLI pipeline):
| Package | Pipeline | Git tag | PyPI name |
|---|---|---|---|
| CLI | azure-pipelines-cli-publish.yml |
cli-v*.*.* |
netgreener |
| SDK | azure-pipelines-sdk-publish.yml |
sdk-v*.*.* |
netgreener_sdk |
Example SDK release: git tag sdk-v0.1.3 && git push origin sdk-v0.1.3
Pre-publish local build (recommended)
Before pushing the sdk-v... tag, verify the wheel/sdist build is clean:
python -m pip install --upgrade pip
python -m pip install build twine
python -m build .
python -m twine check dist/*
JavaScript and TypeScript client
The independently versioned npm package @netgreener/sdk lives in javascript/. Its sources are synchronized from the shared Node runtime SDK implementation. Python packaging and installation remain unchanged.
Metadata
Release files for netgreener-sdk 0.1.5
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 |
|---|---|---|---|---|
| netgreener_sdk-0.1.5.tar.gz | 4.9 MB | Without provenance | Details for netgreener_sdk-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netgreener_sdk-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for netgreener_sdk-0.1.5-py3-none-any.whl |
Total release size: 4.9 MB
Release files / netgreener_sdk-0.1.5.tar.gz
| Download URL | netgreener_sdk-0.1.5.tar.gz |
|---|---|
| Size | 4.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5b376c5773e2c963be27bf4e03959205d8c1becda4142de38ec6cae95ed3135
|
|
BLAKE2b-256 checksum How to use checksums |
c87481b87733b20fb5948e5aa06873bc1263db86fcde336b9a622f03e975239c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Release files / netgreener_sdk-0.1.5-py3-none-any.whl
| Download URL | netgreener_sdk-0.1.5-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d4b56d3bc6ef34cdee3140f698a687142d8e69b77e4ae13b6c40080eb640488
|
|
BLAKE2b-256 checksum How to use checksums |
ae75aa5ba312fa5879c50b026cf7184c0e09d0366dbaeeb64be38b42a37de28f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Security for netgreener-sdk 0.1.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.