pvshow-sdk v0.1.0

SDK & CLI Developer Documentation

Integrate SD2-Agent text-to-image, text-to-video, and image-to-video capabilities into your applications via SDK, CLI, or REST API.

bash
pip install pvshow-sdk

Quick Start

Ensure the SD2-Agent adapter is running, then install the SDK to start generating.

Prerequisites

bash
# Docker Compose
docker compose up -d seedance-adapter

# Or run locally
cd services/seedance-adapter
pip install -r requirements.txt
uvicorn app.main:app --port 8002

30-Second Example

bash
# Text to Video
pvshow text2video -p "一只金毛犬在海边奔跑,阳光明媚"

# Check service health
pvshow health

CLI Reference

After installation, use the pvshow command. Also supports python -m pvshow_sdk.

Global Options

OptionEnv VariableDefaultDescription
--base-url, -uPVSHOW_BASE_URLhttp://localhost:8002SD2-Agent adapter address
--model, -mPVSHOW_MODELsd2-agentModel name

pvshow text2image

Generate images from text prompts.

OptionDefaultDescription
--prompt, -pGeneration prompt (required)
--ratio, -r1:1Aspect ratio (1:1, 16:9, 9:16, 4:3, 3:4)
--resolution2kResolution (1k, 2k)
--no-waitReturn immediately without waiting
bash
pvshow text2image -p "赛博朋克风格的城市夜景,霓虹灯闪烁"
pvshow text2image -p "山水画意境" -r 16:9 --no-wait

pvshow text2video

Generate videos from text prompts.

OptionDefaultDescription
--prompt, -pGeneration prompt (required)
--duration, -d5Duration in seconds
--ratio, -r16:9Aspect ratio
--resolution720pResolution (720p, 1080p)
--no-waitReturn immediately without waiting
bash
pvshow text2video -p "日落时分,海浪拍打沙滩,金色余晖映照水面"
pvshow text2video -p "烟花在夜空绽放" -d 10 --resolution 1080p

pvshow image2video

Animate a first-frame image with a prompt.

OptionDefaultDescription
--prompt, -pGeneration prompt (required)
--image, -iFirst frame image URL (required)
--duration, -d5Duration in seconds
--no-waitReturn immediately without waiting
bash
pvshow image2video \
  -p "让画面中的人物缓缓转头微笑" \
  -i "https://cdn.example.com/portrait.jpg" \
  -d 5

pvshow status / cancel / health

Task management and health check commands.

bash
pvshow status <TASK_ID>    # Query task status
pvshow cancel <TASK_ID>    # Cancel a task
pvshow health              # Health check

Python SDK

Use PVShowClient (sync) or AsyncPVShowClient (async) for programmatic access.

pythonText to Image
from pvshow_sdk import PVShowClient

client = PVShowClient(
    base_url="http://localhost:8002",
    model="sd2-agent",
)

task = client.text2image(
    "一幅莫奈风格的睡莲油画",
    ratio="1:1",
    resolution="2k",
)
result = client.wait(task.id)
print(result.result_url)
pythonText to Video
task = client.text2video(
    "无人机航拍雪山日出,云海翻涌",
    duration=5,
    ratio="16:9",
    resolution="720p",
)
result = client.wait(task.id, poll_interval=5.0, timeout=300.0)
print(result.result_url)
pythonImage to Video
task = client.image2video(
    "让花朵慢慢绽放",
    image_url="https://cdn.example.com/flower.jpg",
    duration=5,
)
result = client.wait(task.id)
print(result.result_url)
pythonTask Management
# Query status
task = client.get_task("your-task-id")
print(task.status)   # processing / completed / failed

# Cancel task
client.cancel("your-task-id")

# Health check
health = client.health()
print(health.status)  # "ok"

# Context manager — auto-close connection
with PVShowClient() as client:
    task = client.text2video("prompt")
    result = client.wait(task.id)

Low-Level submit()

The submit() method provides maximum flexibility — pass any custom parameters.

python
task = client.submit(
    task_type="text_to_video",
    prompt="自定义提示词",
    model="sd2-agent",
    params={
        "duration": 10,
        "ratio": "9:16",
        "video_resolution": "1080p",
        "model_version": "seedance2.0",
    },
)

REST API

The SDK wraps these HTTP endpoints. Non-Python languages can call them directly.

Base URL: http://<host>:8002/api/v1
MethodPathDescription
POST/api/v1/tasks/Create generation task (returns 202)
GET/api/v1/tasks/{task_id}Query task status
POST/api/v1/tasks/{task_id}/cancelCancel a task
GET/api/v1/health/Service health check

POST /api/v1/tasks/ — Request Body

FieldTypeRequiredDescription
task_idstringUnique task ID (UUID recommended)
typestringtext_to_image / text_to_video / image_to_video
modelstringModel name (sd2-agent for Dreamina path)
promptstringGeneration prompt
image_urlstringFirst frame image URL (required for image_to_video)
paramsobjectGeneration parameters (see below)

params

ParameterScopeDefaultDescription
ratioAll1:1 / 16:9Aspect ratio
resolution_typeImage2kImage resolution
durationVideo5Video duration (seconds)
video_resolutionVideo720pVideo resolution
model_versionAllseedance2.0Model version

Response Example

json
{
  "id": "uuid-string",
  "status": "processing",
  "result_url": null,
  "error_message": null,
  "created_at": "2026-04-02T10:30:00+00:00",
  "updated_at": "2026-04-02T10:30:00+00:00"
}

Data Models

TaskResponse

FieldTypeDescription
idstringTask ID
statusstringTask status
result_urlstring | nullResult download URL (available after completion)
error_messagestring | nullError message (on failure)
created_atstringCreated time (ISO 8601)
updated_atstringUpdated time (ISO 8601)

TaskStatus

ValueDescription
queuedQueued
pendingPending
processingGenerating
completedCompleted
failedFailed
cancelledCancelled

TaskType

ValueDescription
text_to_imageText to Image
text_to_videoText to Video
image_to_videoImage to Video

Configuration

Client Environment Variables

Env VariableOptionDefault
PVSHOW_BASE_URL--base-urlhttp://localhost:8002
PVSHOW_MODEL--modelsd2-agent

Adapter Service Environment Variables

Env VariableDefaultDescription
JIMENG_ACCESS_KEYJimeng API Access Key
JIMENG_SECRET_KEYJimeng API Secret Key
JIMENG_API_BASE_URLhttps://api.jimeng.jianying.comJimeng API base URL
DREAMINA_POLL_TIMEOUT120Dreamina CLI poll timeout (seconds)
CALLBACK_BASE_URLhttp://localhost:8000Task callback URL
POLL_INTERVAL_SECONDS10Internal poll interval (seconds)
POLL_MAX_ATTEMPTS120Max poll attempts

Architecture

┌─────────────┐    HTTP     ┌──────────────────────┐
│  pvshow CLI │───────────→│  SD2-Agent Adapter    │
│  / SDK      │            │  (FastAPI :8002)      │
└─────────────┘            │                       │
                           │  ┌─ SD2-Agent ──────┐ │     ┌──────────────┐
                           │  │  Dreamina CLI     │─┼────→│ Dreamina API │
                           │  └──────────────────┘ │     └──────────────┘
                           │                       │
                           │  ┌─ Jimeng ─────────┐ │     ┌──────────────┐
                           │  │  SeedanceClient   │─┼────→│ Jimeng API   │
                           │  │  (HMAC Signing)   │ │     └──────────────┘
                           │  └──────────────────┘ │
                           └───────────┬───────────┘
                                       │ callback
                                       ▼
                           ┌──────────────────────┐
                           │  PVShow Backend       │
                           │  (FastAPI :8000)      │
                           └──────────────────────┘

Model Routing

Model Name ContainsEngineSupported Types
sd2-agentDreamina CLIText to Image / Text to Video / Image to Video
OtherJimeng HTTP API (Seedance 2.0)Text to Video / Image to Video

Task Lifecycle

submit ──→ processing ──→ completed
                     ├──→ failed
                     └──→ cancelled