diff --git a/pyproject.toml b/pyproject.toml index d76f0ae..2e4e958 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pixelvault" -version = "0.5.0" +version = "0.5.1" description = "Official Python SDK for PixelVault, agent-first media hosting" readme = "README.md" license = "MIT" diff --git a/src/pixelvault/_core.py b/src/pixelvault/_core.py index cfc7e6d..6286fe6 100644 --- a/src/pixelvault/_core.py +++ b/src/pixelvault/_core.py @@ -13,7 +13,7 @@ from .errors import PixelVaultError -__version__ = "0.5.0" +__version__ = "0.5.1" DEFAULT_BASE_URL = "https://api.pixelvault.dev" MAX_BACKOFF = 30.0 diff --git a/src/pixelvault/types.py b/src/pixelvault/types.py index a9904cd..50ee6f4 100644 --- a/src/pixelvault/types.py +++ b/src/pixelvault/types.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Dict, List, Optional, TypedDict +from typing import Any, Dict, List, Literal, Optional, TypedDict import sys @@ -73,6 +73,21 @@ class UsageLimits(TypedDict): storage_bytes: int uploads_per_month: int bandwidth_bytes_per_month: int + transforms_per_month: NotRequired[int] + + +class BandwidthUsage(TypedDict): + """CDN bandwidth preflight. Null values are unknown/not applicable, never zero.""" + + status: Literal["available", "unavailable", "unlimited"] + used: Optional[int] + remaining: Optional[int] + limit: Optional[int] + unit: Literal["bytes"] + accounting_period: str + resets_at: str + measured_at: Optional[str] + freshness: Literal["near_real_time", "delayed", "unavailable", "not_applicable"] class GenerationUsage(TypedDict): @@ -80,6 +95,11 @@ class GenerationUsage(TypedDict): credits_limit: int credits_remaining: int +class VideoSecondsUsage(TypedDict): + seconds_used: int + seconds_limit: int + seconds_remaining: int + class Usage(TypedDict): plan: str @@ -90,6 +110,10 @@ class Usage(TypedDict): remaining: UsageCounts #: AI image-generation credits for the month (images.generate). generation: NotRequired[GenerationUsage] + editing: NotRequired[GenerationUsage] + bandwidth: NotRequired[BandwidthUsage] + video_optimization: NotRequired[VideoSecondsUsage] + video_enrichment: NotRequired[VideoSecondsUsage] class ApiKey(TypedDict): diff --git a/tests/test_client.py b/tests/test_client.py index 238ad78..1fd2b35 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -280,13 +280,32 @@ def handler(req: httpx.Request): assert len(calls) == 1 # a lost response must never spend credits twice -def test_usage_exposes_generation_credits(): +def test_usage_exposes_credits_video_quota_and_honest_bandwidth(): usage = { "plan": "free", "generation": {"credits_used": 1, "credits_limit": 10, "credits_remaining": 9}, + "video_optimization": { + "seconds_used": 11, + "seconds_limit": 120, + "seconds_remaining": 109, + }, + "bandwidth": { + "status": "unavailable", + "used": None, + "remaining": None, + "limit": 1_073_741_824, + "unit": "bytes", + "accounting_period": "2026-11", + "resets_at": "2026-12-01T00:00:00.000Z", + "measured_at": None, + "freshness": "unavailable", + }, } got = make(lambda r: httpx.Response(200, json={"data": usage})).usage.get() assert got["generation"]["credits_remaining"] == 9 + assert got["video_optimization"]["seconds_remaining"] == 109 + assert got["bandwidth"]["used"] is None + assert got["bandwidth"]["limit"] == 1_073_741_824 @pytest.mark.asyncio diff --git a/uv.lock b/uv.lock index ff42c05..8af37b8 100644 --- a/uv.lock +++ b/uv.lock @@ -516,7 +516,7 @@ wheels = [ [[package]] name = "pixelvault" -version = "0.5.0" +version = "0.5.1" source = { editable = "." } dependencies = [ { name = "httpx" },