Developing a versioning and licensing system for AI models on the marketplace
Versioning and licensing are critical components of a commercial AI marketplace. Consumers need to know exactly what they're using, and providers need to control access to different versions of their models.
Semantic versioning for AI models
AI models follow semantic versioning, but with ML-specific semantics:
- Major (2.0.0): fundamentally different architecture, incompatible input/output formats, significantly different behavior
- Minor (1.3.0): retraining on new data, improved metrics, backward-compatible behavior changes
- Patch (1.2.1): fixes specific errors, micro-optimizations
from dataclasses import dataclass
from enum import Enum
class ChangeType(Enum):
MAJOR = "major"
MINOR = "minor"
PATCH = "patch"
@dataclass
class ModelVersion:
major: int
minor: int
patch: int
release_notes: str
breaking_changes: list[str]
improvements: list[str]
benchmark_deltas: dict # {"accuracy": +0.02, "latency_ms": -5}
compatibility: dict # {"backward": True, "api_version": "v2"}
def __str__(self):
return f"{self.major}.{self.minor}.{self.patch}"
@property
def is_stable(self):
return self.major > 0 and not self.is_prerelease
class ModelVersionManager:
def create_version(self, model_id: str, artifacts: ModelArtifacts,
change_type: ChangeType) -> ModelVersion:
current = self.get_latest(model_id)
if change_type == ChangeType.MAJOR:
new = ModelVersion(current.major + 1, 0, 0, ...)
elif change_type == ChangeType.MINOR:
new = ModelVersion(current.major, current.minor + 1, 0, ...)
else:
new = ModelVersion(current.major, current.minor, current.patch + 1, ...)
# Автоматический benchmark comparison
new.benchmark_deltas = self.compare_benchmarks(current, artifacts)
return new
Licensing schemes
class LicenseType(Enum):
COMMUNITY = "community" # Бесплатно, некоммерческое использование
DEVELOPER = "developer" # Коммерческое, до N req/month
PROFESSIONAL = "professional" # Без ограничений, SLA 99.9%
ENTERPRISE = "enterprise" # On-premise, custom terms
@dataclass
class License:
type: LicenseType
commercial_use: bool
attribution_required: bool
modification_allowed: bool
redistribution_allowed: bool
derivative_models_allowed: bool
on_premise_allowed: bool
max_monthly_requests: int = None # None = unlimited
geographic_restrictions: list[str] = None
STANDARD_LICENSES = {
LicenseType.COMMUNITY: License(
type=LicenseType.COMMUNITY,
commercial_use=False,
attribution_required=True,
modification_allowed=True,
redistribution_allowed=False,
derivative_models_allowed=False,
on_premise_allowed=False,
max_monthly_requests=10_000
),
LicenseType.ENTERPRISE: License(
type=LicenseType.ENTERPRISE,
commercial_use=True,
attribution_required=False,
modification_allowed=True,
redistribution_allowed=False,
derivative_models_allowed=True,
on_premise_allowed=True,
max_monthly_requests=None
)
}
Marketplace version control API
# Потребитель явно указывает версию в API запросе
@app.post("/v1/models/{model_id}@{version}/predict")
async def predict_versioned(model_id: str, version: str, request: PredictRequest):
# Поддержка alias: "latest", "stable", "2.x" (последняя 2.x версия)
resolved_version = version_resolver.resolve(model_id, version)
return await inference_gateway.run(model_id, resolved_version, request)
# Deprecation уведомления
async def check_deprecated_version_usage(model_id: str, version: str):
version_info = await version_registry.get(model_id, version)
if version_info.deprecated_at:
sunset_date = version_info.sunset_date
days_left = (sunset_date - datetime.utcnow()).days
return {
"deprecated": True,
"message": f"Version {version} deprecated. Sunset in {days_left} days.",
"recommended_version": version_info.replacement
}
Version Lifecycle Policy
- New major version: the previous major version is supported for 12 months
- Deprecation warning 6 months before sunset
- Automatic email notifications to consumers in case of deprecation
- Migration guides are mandatory for breaking changes
This creates a predictable environment for consumers and allows providers to steadily develop models without fear of breaking customers' production systems.







