Skip to main content

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 includes user, access_token, expires_in.
  • set_token(token); use an existing JWT.
  • get_access_token(); current token or None.
  • 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

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.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netgreener-sdk 0.1.4
File Size Uploaded Provenance Actions
netgreener_sdk-0.1.4.tar.gz 4.9 MB Without provenance Details for netgreener_sdk-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netgreener-sdk 0.1.4
File Interpreter ABI Platform Actions
netgreener_sdk-0.1.4-py3-none-any.whl Python 3 none any Details for netgreener_sdk-0.1.4-py3-none-any.whl

Total release size: 4.9 MB

Release files / netgreener_sdk-0.1.4.tar.gz

Download URL netgreener_sdk-0.1.4.tar.gz
Size 4.9 MB
Tags Source
SHA-256 checksum
How to use checksums
f6238107d017a998dbae00fdd8308a2bba8c663a808c147f4d935d205caa5cbc
BLAKE2b-256 checksum
How to use checksums
3b23dfaa4457431f0019a70c831af268016101c73f9c6313a76823d8c19174dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / netgreener_sdk-0.1.4-py3-none-any.whl

Download URL netgreener_sdk-0.1.4-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6605515a9fdbfdfd115b7358e3568db51a74afc8165d916392b91017ad9a49e7
BLAKE2b-256 checksum
How to use checksums
22fdfca7270b8d781ed5bdd5229308b0a968ea999a8a5da01595aa06b050264a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for netgreener-sdk 0.1.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page