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

# 建立 Runway 角色表演

> 使用 CometAPI 搭配 Runway Control a character API，從參考影片啟動角色表演任務，驅動臉部表情與身體動作。

使用這個端點可將參考片段中的表演轉移到角色圖片或角色影片上。

## 呼叫前準備

* 傳送必要的 `X-Runway-Version` 標頭，例如 `2024-11-06`
* 使用 `model: act_two`
* 提供一個 `character` 資產與一個 `reference` 資產，且都必須是可存取的 HTTPS URL
* 在調整風格前，先以 `bodyControl: true` 和適中的 `expressionIntensity` 開始

## 輸出比例

| 設定      | 支援的值                                                   | 預設起始值      | 邊界行為                  |
| ------- | ------------------------------------------------------ | ---------- | --------------------- |
| `ratio` | `1280:720`、`720:1280`，或所選 Runway model/version 接受的其他比例 | `1280:720` | 讓角色與參考資產盡量接近所要求的畫面比例。 |

## 任務流程

<Steps>
  <Step title="提交角色表演請求">
    使用你的角色資產、參考資產與動作設定建立任務。
  </Step>

  <Step title="儲存回傳的 task id">
    保留回傳的 `id`，因為後續輪詢會用到它。
  </Step>

  <Step title="輪詢任務狀態">
    持續使用[取得 Runway 任務](./runway-to-get-task-details)，直到任務進入終態，且提供者中繼資料包含完成的輸出。
  </Step>
</Steps>

## 輸入角色

* `character` 是你想要製作動畫的主體
* `reference` 是提供臉部表演或身體動作的來源片段
* `bodyControl` 決定動作轉移是否除了表情轉移外，也包含身體動作
* `contentModeration` 會將提供者的審核門檻套用到此請求


## OpenAPI

````yaml api/openapi/video/runway/official-format/post-control-a-character.openapi.json POST /runwayml/v1/character_performance
openapi: 3.1.0
info:
  title: Control a Character API
  version: 1.0.0
  description: >-
    Create a Runway character-performance task through the official-format
    CometAPI route.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /runwayml/v1/character_performance:
    post:
      summary: Create a Runway character-performance task
      description: >-
        Submit a character asset plus a reference performance clip and receive a
        task id for later polling.
      operationId: control_a_character
      parameters:
        - name: X-Runway-Version
          in: header
          required: true
          description: Runway version header, for example `2024-11-06`.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - character
                - reference
                - bodyControl
                - expressionIntensity
                - seed
                - model
                - ratio
                - contentModeration
              properties:
                character:
                  type: object
                  description: >-
                    The character to control. You can either provide a video or
                    an image.
                  required:
                    - type
                    - uri
                  properties:
                    type:
                      type: string
                    uri:
                      type: string
                  default:
                    type: video
                    uri: https://your-video-host/source.mp4
                reference:
                  type: object
                  description: >-
                    Reference performance clip. Provide `type` (`video`) and
                    `uri` (HTTPS URL).
                  required:
                    - type
                    - uri
                  properties:
                    type:
                      type: string
                    uri:
                      type: string
                  default:
                    type: video
                    uri: https://your-video-host/source.mp4
                bodyControl:
                  type: boolean
                  description: Enable body control.
                  default: true
                expressionIntensity:
                  type: integer
                  description: >-
                    Intensity of the expression transfer. Higher values produce
                    more exaggerated expressions.
                  default: 1
                seed:
                  type: integer
                  description: Random seed for reproducible results.
                  default: 1
                model:
                  type: string
                  description: The model variant to use. Must be act_two.
                  default: act_two
                ratio:
                  type: string
                  description: >-
                    Requested output frame shape, for example 1280:720 or
                    720:1280. Keep the character and reference assets close to
                    the requested frame shape.
                  default: '1280:720'
                contentModeration:
                  type: object
                  required:
                    - publicFigureThreshold
                  properties:
                    publicFigureThreshold:
                      type: string
                      description: >-
                        Threshold for public-figure detection. Use `auto` for
                        default behavior.
                  default:
                    publicFigureThreshold: auto
              default:
                character:
                  type: video
                  uri: https://your-video-host/source.mp4
                reference:
                  type: video
                  uri: https://your-video-host/source.mp4
                bodyControl: true
                expressionIntensity: 1
                seed: 1
                model: act_two
                ratio: '1280:720'
                contentModeration:
                  publicFigureThreshold: auto
            examples:
              Default:
                summary: Default
                value:
                  character:
                    type: video
                    uri: https://your-video-host/source.mp4
                  reference:
                    type: video
                    uri: https://your-video-host/source.mp4
                  bodyControl: true
                  expressionIntensity: 3
                  seed: 4294967295
                  model: act_two
                  ratio: '1280:720'
                  contentModeration:
                    publicFigureThreshold: auto
      responses:
        '200':
          description: Task accepted.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                properties:
                  id:
                    type: string
                example:
                  id: 5b91e444-c232-deaf-a4d7-8aef3e57336b
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/runwayml/v1/character_performance \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "character": {
                    "type": "video",
                    "uri": "https://your-video-host/character.mp4"
                  },
                  "reference": {
                    "type": "video",
                    "uri": "https://your-video-host/performance.mp4"
                  },
                  "model": "act_two",
                  "ratio": "1280:720"
                }'
        - lang: Python
          label: Default
          source: >
            import os

            import requests


            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/character_performance",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                        "character": {
                                "type": "video",
                                "uri": "https://your-video-host/character.mp4"
                        },
                        "reference": {
                                "type": "video",
                                "uri": "https://your-video-host/performance.mp4"
                        },
                        "model": "act_two",
                        "ratio": "1280:720"
                },
            )


            task = response.json()

            print(task["id"])  # poll GET /runwayml/v1/tasks/{id} until the
            output array appears
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/runwayml/v1/character_performance",
            {
                method: "POST",
                headers: {
                    Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                        "character": {
                            "type": "video",
                            "uri": "https://your-video-host/character.mp4"
                        },
                        "reference": {
                            "type": "video",
                            "uri": "https://your-video-host/performance.mp4"
                        },
                        "model": "act_two",
                        "ratio": "1280:720"
                    }),
            });


            const task = await response.json();

            console.log(task.id); // poll GET /runwayml/v1/tasks/{id} until the
            output array appears
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````