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

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.6
File Size Uploaded Provenance Actions
netgreener_sdk-0.1.6.tar.gz 4.9 MB Without provenance Details for netgreener_sdk-0.1.6.tar.gz

Built distribution (wheel)

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

Total release size: 4.9 MB

Release files / netgreener_sdk-0.1.6.tar.gz

Download URL netgreener_sdk-0.1.6.tar.gz
Size 4.9 MB
Tags Source
SHA-256 checksum
How to use checksums
2dcc512649f0ce2dcf140d15158f8f6c09406777a71a12cec32abceeee9b303f
BLAKE2b-256 checksum
How to use checksums
f1f48196f0f779bc8a7f486b4773e6d66ebf967d78076fd5f920964bf03be34b
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.6-py3-none-any.whl

Download URL netgreener_sdk-0.1.6-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a00ba0c61bb4879aed0ea70700c2558afb0ad18ab9ea19d0ac1ce2bc9e018c87
BLAKE2b-256 checksum
How to use checksums
cb1e8c050b9b4638521b1057928dc72eb95f36406e4d66a1a776f6e507dcaf16
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.6

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