Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
110 lines
3.6 KiB
Python
110 lines
3.6 KiB
Python
"""Canonical public request and response models for Prism Sx0."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field, model_validator
|
|
|
|
|
|
class RoutingPreferences(BaseModel):
|
|
fallback: Literal["none", "equivalent"] = "equivalent"
|
|
max_cost_micros: int | None = Field(default=None, gt=0)
|
|
sort: Literal["price", "latency"] = "price"
|
|
provider_order: list[str] = Field(default_factory=list, max_length=20)
|
|
|
|
|
|
class GenerationRequest(BaseModel):
|
|
model: str = Field(min_length=1, max_length=160)
|
|
prompt: str = Field(min_length=1, max_length=8_000)
|
|
modality: Literal["image", "video", "audio"] | None = None
|
|
duration_seconds: int = Field(default=5, ge=1, le=60)
|
|
aspect_ratio: Literal["9:16", "16:9"] = "9:16"
|
|
image_url: str | None = Field(default=None, max_length=2_048)
|
|
# Audio/voice modality inputs. ``voice_id`` selects a provider voice (e.g. a
|
|
# cloned or catalog voice), ``reference_audio_url`` supplies a reference clip
|
|
# for voice cloning / style transfer, ``instrumental`` requests music without
|
|
# vocals, and ``language`` is an optional TTS language hint. All are ignored by
|
|
# image/video models; providers read only the fields they support.
|
|
voice_id: str | None = Field(default=None, max_length=256)
|
|
reference_audio_url: str | None = Field(default=None, max_length=2_048)
|
|
instrumental: bool = False
|
|
language: str | None = Field(default=None, max_length=32)
|
|
routing: RoutingPreferences = Field(default_factory=RoutingPreferences)
|
|
|
|
@model_validator(mode="after")
|
|
def require_image_for_i2v(self) -> "GenerationRequest":
|
|
if self.model.endswith("-i2v") and not self.image_url:
|
|
raise ValueError("image_url is required for image-to-video models")
|
|
return self
|
|
|
|
|
|
class Attempt(BaseModel):
|
|
model: str
|
|
provider: str
|
|
outcome: Literal["failed", "submitted", "completed"]
|
|
|
|
|
|
class SettlementReceipt(BaseModel):
|
|
"""Privacy-safe projection of Mint's signed terminal receipt."""
|
|
|
|
operation: Literal["hold.capture", "hold.release"]
|
|
sequence: int = Field(gt=0)
|
|
amount_micros: int = Field(ge=0)
|
|
operation_hash: str = Field(min_length=1)
|
|
receipt_hash: str = Field(min_length=1)
|
|
signature: str = Field(min_length=1)
|
|
signer: str = ""
|
|
|
|
|
|
class GenerationSettlement(BaseModel):
|
|
"""Public state of the success-only billing command for a generation."""
|
|
|
|
status: Literal[
|
|
"authorized",
|
|
"capture_pending",
|
|
"captured",
|
|
"release_pending",
|
|
"released",
|
|
]
|
|
reserved_micros: int = Field(gt=0)
|
|
charged_micros: int = Field(ge=0)
|
|
receipt: SettlementReceipt | None = None
|
|
|
|
|
|
class GenerationResponse(BaseModel):
|
|
id: str
|
|
correlation_id: str = Field(min_length=1, max_length=128)
|
|
object: Literal["media.generation"] = "media.generation"
|
|
status: Literal["queued", "running", "completed", "failed"]
|
|
model: str
|
|
provider: str
|
|
modality: Literal["image", "video", "audio"]
|
|
output_url: str = ""
|
|
error: str = ""
|
|
provider_ref: str = ""
|
|
cost_micros: int = Field(ge=0)
|
|
currency: Literal["USD"] = "USD"
|
|
attempts: list[Attempt]
|
|
settlement: GenerationSettlement | None = None
|
|
|
|
|
|
class GenerationListResponse(BaseModel):
|
|
object: Literal["list"] = "list"
|
|
data: list[GenerationResponse]
|
|
|
|
|
|
class ModelResponse(BaseModel):
|
|
id: str
|
|
object: Literal["model"] = "model"
|
|
modality: Literal["image", "video", "audio"]
|
|
provider: str
|
|
price_micros: int
|
|
unit: str
|
|
description: str = ""
|
|
|
|
|
|
class ModelListResponse(BaseModel):
|
|
object: Literal["list"] = "list"
|
|
data: list[ModelResponse]
|