Skip to main content

The official Serial Alice SDK — certify AI energy consumption in one function call

Project description

Serial Alice SDK for Python

The official Python SDK for Serial Alice — certify AI energy consumption in one function call.

Install

pip install serialalice

No required dependencies. Uses requests if available, falls back to stdlib urllib.

Quick start

from serialalice import SerialAlice

alice = SerialAlice(api_key="sa_xxx")

cert = alice.certify({
    "model":            "mistralai/Mistral-7B-Instruct-v0.3",
    "hardware":         "H100-SXM-80GB",
    "provider":         "RunPod",
    "energy_wh":        0.00419,
    "tokens_input":     50,
    "tokens_output":    200,
    "duration_seconds": 4.2,
})

print(cert.id)              # sa-abc123...
print(cert.verify_url)      # https://api.serialalice.pt/...
print(cert.trust_score)     # 0.85
print(cert.signature_valid) # True
print(cert.anchor_status)   # PENDING → ANCHORED

Certificate object

cert.id               # "sa-abc123..."
cert.verify_url       # public verification URL (no auth)
cert.download_url     # full certificate bundle URL
cert.signature_valid  # Ed25519 signature intact
cert.anchor_status    # "PENDING" | "ANCHORED" | "FAILED"
cert.anchor_tx        # Polygon tx hash (once anchored)
cert.trust_score      # 0.0–1.0
cert.trust_posture    # "hardware_measured" | "self_reported"
cert.claim_type       # "hardware_measured" | "scheduling_decision"
cert.energy_wh        # measured energy in Wh
cert.uwh_per_token    # µWh per output token
cert.model_id         # HuggingFace model ID
cert.hardware         # GPU label
cert.issued_at        # ISO 8601 timestamp

# Methods
bundle = cert.download_bundle()   # full signed JSON bundle
valid  = cert.verify()            # re-check signature now
d      = cert.to_dict()           # export as plain dict

Auto-derived fields

You don't need to provide:

  • tokens_total — derived as tokens_input + tokens_output
  • uwh_per_token — derived as energy_wh * 1e6 / tokens_output
  • nvml_samples — derived as duration_seconds * 10
  • batch_size — defaults to 1

Other methods

# Retrieve an existing certificate
cert = alice.get_certificate("sa-abc123...")

# Quick signature check (public endpoint)
valid = alice.verify("sa-abc123...")

# List recent certificates for this tenant
certs = alice.list_certificates(limit=20)

Error handling

from serialalice import (
    SerialAlice,
    AuthenticationError,   # invalid API key or missing scope
    IssuanceError,         # server rejected the request
    ValidationError,       # invalid workload payload
    TimeoutError,          # polling timed out
    NotFoundError,         # certificate not found
)

try:
    cert = alice.certify(workload)
except AuthenticationError:
    print("Check your API key and scopes")
except ValidationError as e:
    print(f"Bad payload: {e}")
except TimeoutError:
    print("Try increasing poll_timeout")

Configuration

alice = SerialAlice(
    api_key="sa_xxx",
    base_url="https://api.serialalice.pt",   # default
    poll_interval=1.0,   # seconds between polls (default: 1)
    poll_timeout=60.0,   # max wait for cert (default: 60)
    timeout=30.0,        # HTTP request timeout (default: 30)
)

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

serialalice-1.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

serialalice-1.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file serialalice-1.1.0.tar.gz.

File metadata

  • Download URL: serialalice-1.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for serialalice-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e731bbc30a533a0f5e03652065b74223d5a6cfd52e1324a928fd39509617f77d
MD5 252fe1aceab607c543fbff356d7d10cd
BLAKE2b-256 50b35d020f25d066f124af8eb56a194e803bfe15c31f5d0dde4c7a61ef006467

See more details on using hashes here.

File details

Details for the file serialalice-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: serialalice-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for serialalice-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c468232492d2246e66f4bdcf809201c4c3d20bfea5d6322496c47d481ba4fe5f
MD5 611203fe7d693caced4471de2293f3b4
BLAKE2b-256 23e5bb2a9d15252b8b0defe282cb151cf22c4d0e80f654c5ed4b708bc59c52d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page