> ## 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.

# Opprett en Runway-oppgave for video-til-video

> Rediger en video med Runway Aleph 2 via CometAPI ved hjelp av en Prompt i tekstform, tidsbestemte veiledningsbilder og et valgfritt målsideforhold.

Bruk `aleph2` til å redigere en kildevideo med en Prompt i tekstform. Forespørselen returnerer en
oppgave `id`; hent oppgavedetaljer for å få det ferdige resultatet.

## Klargjør forespørselen

* Autentiser med CometAPI API-nøkkelen din.
* Sett `model` til `aleph2`, og oppgi `videoUri` for en video på opptil 30 sekunder.
* Valgfritt: inkluder `promptText` for å beskrive redigeringen, med 1 til 1 000
  tegn. Du kan også utelate den når du bruker nøkkelbilder.
* Erstatt eksempel-URL-en for mediet med en tilgjengelig HTTPS-URL. Mediefeltene
  godtar også Base64-data-URI-er med en kodet størrelse på opptil 5 MB.

## Legg til tidsbestemte veiledningsbilder

For å veilede bestemte øyeblikk kan du oppgi ett til fem objekter i `keyframes`.
Hvert objekt inneholder et bilde via `uri` og nøyaktig én posisjon:

| Felt                  | Betydning                                                                        |
| --------------------- | -------------------------------------------------------------------------------- |
| `seconds`             | Tidsstempel fra videostarten, fra `0` til `30` sekunder.                         |
| `at`                  | Andel av videovarigheten, fra `0` til og med `1`.                                |
| `range.start_seconds` | Inkluderende start på et valgfritt redigeringsvindu, i hele sekunder.            |
| `range.end_seconds`   | Ekskluderende slutt på det vinduet, i hele sekunder; må være større enn starten. |

Tidsstempelet for nøkkelbildet må ligge innenfor redigeringsvinduet. Hvis du bruker `range`,
angir du det på hvert nøkkelbilde. Ellers utelater du `range` fra hvert nøkkelbilde.
Utelat `keyframes` når du ikke trenger veiledningsbilder. En tom matrise eller
`null` regnes som utelatelse.

## Velg rammeform og format

Bruk `targetAspectRatio` for å be om utvidelse til `16:9`, `4:3`, `3:2`, `1:1`,
`2:3`, `3:4`, `9:16`, eller `21:9`. Inndatavideoen og veiledningsbildene blir
tilpasset med svarte kanter til denne formen før generering. Det utgåtte feltet `ratio`
er valgfritt; bruk `targetAspectRatio` for å styre sideforholdet.

| `outputFormat`     | Utdata                                 |
| ------------------ | -------------------------------------- |
| `mp4`              | H.264 MP4; brukes når feltet utelates. |
| `prores`           | ProRes MOV.                            |
| `png_sequence`     | ZIP-arkiv som inneholder PNG-bilder.   |
| `sdr_rec709_10bit` | 10-bit Rec.709 HEVC MP4.               |

Hvis `outputFormat` er `prores`, kan du sette `proresProfile` til `422`, `4444`,
`422 Proxy`, `422 LT`, `422 HQ`, eller `4444 XQ`. Standardprofilen er `4444`.
Alfakanalen i `4444` og `4444 XQ` er ugjennomsiktig. Utelat `proresProfile`
for andre utdataformater.

For et eksplisitt samplingfrø bruker du `1` til `4294967295`. Utelat `seed`
for et tilfeldig frø; `0` regnes som utelatelse.

## Hent resultatet

Lagre den returnerte `id`, og bruk
[Hent en Runway-oppgave](./runway-to-get-task-details) for å hente oppgavestatusen.
Når `status` er `SUCCEEDED`, leser du resultat-URL-ene fra `output`. Hvis oppgaven
mislykkes, undersøk `failure` og `failureCode` når de finnes.


## OpenAPI

````yaml api/openapi/video/runway/official-format/post-generate-a-video-from-a-video.openapi.json POST /runwayml/v1/video_to_video
openapi: 3.1.0
info:
  title: Create a Runway video-to-video task
  version: 1.0.0
  description: Create an asynchronous Runway task through CometAPI.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /runwayml/v1/video_to_video:
    post:
      summary: Create a Runway video-to-video task
      description: >-
        Submit the request and save the returned id. Retrieve task details to
        read the status and output URLs.
      operationId: generate_a_video_from_a_video
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Aleph 2 video-editing request.
              properties:
                model:
                  type: string
                  description: Model ID for this request.
                  enum:
                    - aleph2
                videoUri:
                  description: >-
                    Input video to edit, with a maximum duration of 30 seconds.
                    Use an accessible HTTPS URL or a Base64 data URI with an
                    encoded size of up to 5 MB.
                  oneOf:
                    - type: string
                      description: Accessible HTTPS URL of the video.
                      pattern: ^https://
                      maxLength: 2048
                      minLength: 13
                    - type: string
                      description: Base64-encoded video, including its data URI prefix.
                      pattern: ^data:video/[^;]+;base64,
                      maxLength: 5242880
                      minLength: 13
                promptText:
                  type: string
                  description: >-
                    Optional instruction describing the edit, from 1 to 1,000
                    characters. Can be omitted when using keyframes.
                  minLength: 1
                  maxLength: 1000
                keyframes:
                  type:
                    - array
                    - 'null'
                  description: >-
                    One to five timed guidance images. Each image uses exactly
                    one of seconds or at. Omit when no guidance images are
                    needed; an empty array or null is treated as omission.
                  minItems: 0
                  maxItems: 5
                  items:
                    oneOf:
                      - type: object
                        description: Guidance image positioned using seconds.
                        properties:
                          uri:
                            description: >-
                              Guidance image for this point in the video. Use an
                              accessible HTTPS URL or a Base64 data URI with an
                              encoded size of up to 5 MB.
                            oneOf:
                              - type: string
                                description: Accessible HTTPS URL of the image.
                                pattern: ^https://
                                maxLength: 2048
                                minLength: 13
                              - type: string
                                description: >-
                                  Base64-encoded image, including its data URI
                                  prefix.
                                pattern: ^data:image/[^;]+;base64,
                                maxLength: 5242880
                                minLength: 13
                          seconds:
                            type: number
                            description: >-
                              Absolute timestamp from the start of the video, in
                              seconds.
                            minimum: 0
                            maximum: 30
                          range:
                            type: object
                            description: >-
                              Edit window in whole seconds. The keyframe
                              timestamp must be inside this window. Set a range
                              on every keyframe or on none.
                            properties:
                              start_seconds:
                                type: integer
                                description: >-
                                  Inclusive start of the edit window, in whole
                                  seconds.
                                minimum: 0
                              end_seconds:
                                type: integer
                                description: >-
                                  Exclusive end of the edit window, in whole
                                  seconds. Must exceed start_seconds.
                                minimum: 1
                            required:
                              - start_seconds
                              - end_seconds
                            additionalProperties: false
                        required:
                          - uri
                          - seconds
                        additionalProperties: false
                      - type: object
                        description: Guidance image positioned using at.
                        properties:
                          uri:
                            description: >-
                              Guidance image for this point in the video. Use an
                              accessible HTTPS URL or a Base64 data URI with an
                              encoded size of up to 5 MB.
                            oneOf:
                              - type: string
                                description: Accessible HTTPS URL of the image.
                                pattern: ^https://
                                maxLength: 2048
                                minLength: 13
                              - type: string
                                description: >-
                                  Base64-encoded image, including its data URI
                                  prefix.
                                pattern: ^data:image/[^;]+;base64,
                                maxLength: 5242880
                                minLength: 13
                          at:
                            type: number
                            description: >-
                              Position as a fraction of the input video
                              duration, from 0 through 1.
                            minimum: 0
                            maximum: 1
                          range:
                            type: object
                            description: >-
                              Edit window in whole seconds. The keyframe
                              timestamp must be inside this window. Set a range
                              on every keyframe or on none.
                            properties:
                              start_seconds:
                                type: integer
                                description: >-
                                  Inclusive start of the edit window, in whole
                                  seconds.
                                minimum: 0
                              end_seconds:
                                type: integer
                                description: >-
                                  Exclusive end of the edit window, in whole
                                  seconds. Must exceed start_seconds.
                                minimum: 1
                            required:
                              - start_seconds
                              - end_seconds
                            additionalProperties: false
                        required:
                          - uri
                          - at
                        additionalProperties: false
                targetAspectRatio:
                  type: string
                  description: >-
                    Target aspect ratio for expansion. The input video and
                    keyframes are letterboxed to this shape before generation.
                  enum:
                    - '16:9'
                    - '4:3'
                    - '3:2'
                    - '1:1'
                    - '2:3'
                    - '3:4'
                    - '9:16'
                    - '21:9'
                ratio:
                  type: string
                  description: >-
                    Deprecated aspect-ratio field. Use targetAspectRatio
                    instead.
                  deprecated: true
                seed:
                  type: integer
                  description: >-
                    Sampling seed. Omit for a random seed; 0 is treated as
                    omission.
                  minimum: 0
                  maximum: 4294967295
                outputFormat:
                  type: string
                  description: >-
                    Output format: mp4 for H.264 MP4, prores for ProRes MOV,
                    png_sequence for a ZIP of PNG frames, or sdr_rec709_10bit
                    for 10-bit Rec.709 HEVC MP4. Omit for mp4.
                  enum:
                    - mp4
                    - prores
                    - png_sequence
                    - sdr_rec709_10bit
                proresProfile:
                  type: string
                  description: >-
                    ProRes profile. Include only with outputFormat set to
                    prores; omit for 4444. The 4444 and 4444 XQ profiles have an
                    opaque alpha channel.
                  enum:
                    - '422'
                    - '4444'
                    - 422 Proxy
                    - 422 LT
                    - 422 HQ
                    - 4444 XQ
                contentModeration:
                  type: object
                  description: >-
                    Content moderation settings. Omit to use the standard
                    settings.
                  properties:
                    publicFigureThreshold:
                      type: string
                      description: >-
                        Public-figure detection threshold. Use auto for standard
                        detection or low for less restrictive detection.
                      enum:
                        - auto
                        - low
                  required:
                    - publicFigureThreshold
                  additionalProperties: false
              required:
                - model
                - videoUri
              additionalProperties: false
              dependentSchemas:
                proresProfile:
                  properties:
                    outputFormat:
                      const: prores
                      description: Use prores when proresProfile is supplied.
                  required:
                    - outputFormat
            example:
              model: aleph2
              videoUri: https://example.com/source-video.mp4
              promptText: Turn the daytime scene into a snowy winter evening.
      responses:
        '200':
          description: The task was created. Save its id for task retrieval.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Task ID for GET /runwayml/v1/tasks/{id}.
                  status:
                    type: string
                    description: Task state, when returned.
                  createdAt:
                    type: string
                    description: Task submission timestamp, when returned.
                    format: date-time
                  output:
                    type: array
                    description: Result URLs, when returned.
                    items:
                      type: string
                      format: uri
                  failure:
                    type: string
                    description: Failure explanation, when returned.
                  failureCode:
                    type: string
                    description: Machine-readable failure code, when returned.
                  estimatedCost:
                    type: object
                    description: Task estimate metadata, when returned.
                    properties:
                      credits:
                        type: integer
                        description: Credit value reported with the task.
                    required:
                      - credits
                    additionalProperties: false
                  cost:
                    type: object
                    description: Task cost metadata, when returned.
                    properties:
                      credits:
                        type: integer
                        description: Credit value reported with the task.
                    required:
                      - credits
                    additionalProperties: false
                required:
                  - id
                additionalProperties: false
              example:
                id: 00000000-0000-4000-8000-000000000000
        '400':
          description: Invalid request or unavailable task ID.
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    description: Task request error.
                    properties:
                      code:
                        type:
                          - string
                          - integer
                        description: Machine-readable task error code.
                      message:
                        type: string
                        description: Error explanation.
                      data:
                        description: Additional error details, when returned.
                    required:
                      - code
                      - message
                    additionalProperties: true
                  - type: object
                    description: Request authentication or validation error.
                    properties:
                      error:
                        type: object
                        description: Error details.
                        properties:
                          message:
                            type: string
                            description: Error explanation.
                          type:
                            type: string
                            description: Error category.
                          code:
                            type:
                              - string
                              - integer
                              - 'null'
                            description: Error code, when returned.
                        required:
                          - message
                        additionalProperties: true
                    required:
                      - error
                    additionalProperties: true
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                type: object
                description: Request authentication or validation error.
                properties:
                  error:
                    type: object
                    description: Error details.
                    properties:
                      message:
                        type: string
                        description: Error explanation.
                      type:
                        type: string
                        description: Error category.
                      code:
                        type:
                          - string
                          - integer
                          - 'null'
                        description: Error code, when returned.
                    required:
                      - message
                    additionalProperties: true
                required:
                  - error
                additionalProperties: true
      x-codeSamples:
        - lang: Shell
          source: |-
            curl --request POST \
              --url https://api.cometapi.com/runwayml/v1/video_to_video \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "aleph2",
              "videoUri": "https://example.com/source-video.mp4",
              "promptText": "Turn the daytime scene into a snowy winter evening."
            }'
        - lang: Python
          source: |-
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/video_to_video",
                headers={"Authorization": f"Bearer {os.environ['COMETAPI_KEY']}"},
                json={
                  "model": "aleph2",
                  "videoUri": "https://example.com/source-video.mp4",
                  "promptText": "Turn the daytime scene into a snowy winter evening."
                },
            )
            response.raise_for_status()
            print(response.json())
        - lang: JavaScript
          source: |-
            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/video_to_video",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify({
                  "model": "aleph2",
                  "videoUri": "https://example.com/source-video.mp4",
                  "promptText": "Turn the daytime scene into a snowy winter evening."
                }),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            console.log(await response.json());
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your CometAPI API key.

````