> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prismgateway.io/llms.txt
> Use this file to discover all available pages before exploring further.

# ตัวอย่างรูปภาพและวิดีโอ

> ตัวอย่าง OpenAI-style media requests สำหรับ Seedream, Seedance, HappyHorse 1.1, และ HappyHorse-compatible video jobs.

# ตัวอย่างรูปภาพและวิดีโอ

ใช้ Facade host และ Prism API key เดียวกับ chat completions:

```bash theme={null}
export PRISM_BASE_URL="https://api.prismgateway.io/v1"
export PRISM_API_KEY="sk-prism-..."
```

ใช้ `GET /v1/models` หรือ console model catalog เพื่อเลือก public model ID ที่ org ของคุณมองเห็น ตัวอย่างด้านล่างแสดง request shape ที่รองรับ ให้แทนที่ model ID ด้วย ID ที่ publish จริงใน catalog ของคุณ

## สร้างรูปภาพ

`POST /v1/images/generations` รับ OpenAI-style image generation body โดย Facade จะตรวจ customer key, catalog visibility, credits แล้ว route ไป image runtime ที่ตั้งค่าไว้

```bash theme={null}
curl -sS "$PRISM_BASE_URL/images/generations" \
  -H "Authorization: Bearer $PRISM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream-5-0-260128",
    "prompt": "A clean product render of a translucent prism gateway device on a white desk",
    "size": "1024x1024",
    "n": 1
  }'
```

เมื่อ runtime รองรับ response จะเป็น OpenAI image shape:

```json theme={null}
{
  "created": 1779091200,
  "data": [
    {
      "url": "https://..."
    }
  ]
}
```

## Text-to-video

สร้าง video job ด้วย `POST /v1/video/generations` วิดีโอเป็น async ให้เก็บ job ID ที่ได้กลับมา แล้ว poll ด้วย `GET /v1/video/generations/{jobId}`

```bash theme={null}
curl -sS "$PRISM_BASE_URL/video/generations" \
  -H "Authorization: Bearer $PRISM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-1.0-pro-fast",
    "prompt": "A cinematic dolly shot through a glass API gateway room, soft reflections, product demo style",
    "duration": 5,
    "resolution": "1080p",
    "aspectRatio": "16:9",
    "generateAudio": true
  }'
```

## Image-to-video

ส่ง hosted image URL ไปพร้อม video request ได้ `prompt` ใช้อธิบาย motion ส่วน media-only requests รองรับใน video runtime ที่รองรับ image หรือ reference inputs

```bash theme={null}
curl -sS "$PRISM_BASE_URL/video/generations" \
  -H "Authorization: Bearer $PRISM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-1.0-pro-fast",
    "prompt": "Animate the product with a slow clockwise camera move and subtle light sweep",
    "imageUrl": "https://cdn.example.com/prism/product-frame.png",
    "duration": 5,
    "resolution": "1080p",
    "aspectRatio": "16:9"
  }'
```

## HappyHorse 1.1 text-to-video

HappyHorse 1.1 เป็น video model ใหม่ล่าสุดจาก Alibaba มี cinematic lighting, กล้องนิ่ง, และสร้าง audio ได้ในตัว ใช้ `happyhorse-1.1-t2v` สำหรับ text-to-video

```bash theme={null}
curl -sS "$PRISM_BASE_URL/video/generations" \
  -H "Authorization: Bearer $PRISM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "happyhorse-1.1-t2v",
    "prompt": "A cinematic aerial shot of a tropical island at golden hour, lush vegetation and crystal-clear water",
    "duration": 5,
    "resolution": "1080p",
    "aspectRatio": "16:9",
    "generateAudio": true
  }'
```

## HappyHorse reference-to-video

HappyHorse-compatible request shapes รองรับ `imageUrls` สำหรับ multi-reference video generation และ audio controls เช่น `generateAudio` กับ `refAudioUrl`

```bash theme={null}
curl -sS "$PRISM_BASE_URL/video/generations" \
  -H "Authorization: Bearer $PRISM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "happyhorse-1.1-r2v",
    "imageUrls": [
      "https://cdn.example.com/character/front.png",
      "https://cdn.example.com/character/side.png"
    ],
    "prompt": "A short studio walk cycle with consistent character identity",
    "generateAudio": true,
    "refAudioUrl": "https://cdn.example.com/audio/reference-voice.wav"
  }'
```

## Video edit

สำหรับ video edit models ให้ส่ง `refVideoUrl` ส่วน prompt ใช้อธิบาย edit intent ได้ แต่ media input คือ anchor หลักของคำขอ

```bash theme={null}
curl -sS "$PRISM_BASE_URL/video/generations" \
  -H "Authorization: Bearer $PRISM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "happyhorse-1.1-video-edit",
    "refVideoUrl": "https://cdn.example.com/source/product-demo.mp4",
    "prompt": "Replace the background with a bright product launch stage while preserving the subject motion",
    "generateAudio": false
  }'
```

## Poll video job

```bash theme={null}
curl -sS "$PRISM_BASE_URL/video/generations/$JOB_ID" \
  -H "Authorization: Bearer $PRISM_API_KEY"
```

## หมายเหตุปฏิบัติการ

* Video และ image model IDs ต้องอยู่ใน `GET /v1/models` ของ API key ที่เรียก
* ตอนนี้ media input รองรับเฉพาะ URL request body ไม่รับ file upload ให้ host
  ไฟล์ไว้บน HTTPS URL ที่ runtime เข้าถึงได้ และควรใช้ short-lived URL หากทำได้
* ถ้า model เป็น draft, มองไม่เห็น, ไม่ได้ตั้ง modality ที่เรียก, หรือ provider credentials ยังไม่ครบ Facade จะคืน catalog/runtime configuration error

ดูวิธีจัดการ failure ที่ [Errors](/th/errors) และข้อจำกัด trial ที่ [Billing
และ trials](/th/billing-and-trials)
