> ## 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 image-to-video

> Animer et kildebilde med Gen-4.5 eller Gen-4 Turbo, og hent resultatet som en Runway-oppgave.

Bruk dette endepunktet til å animere et kildebilde. Send CometAPI API-nøkkelen din med
Bearer-autentisering og en JSON-forespørselstekst.

## Velg en modell

| Modell       | Obligatoriske felt                                        | Prompt for bevegelse                                                                     |
| ------------ | --------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| `gen4.5`     | `model`, `promptImage`, `promptText`, `ratio`, `duration` | Beskriv bevegelsen i `promptText`.                                                       |
| `gen4_turbo` | `model`, `promptImage`, `ratio`                           | Du kan eventuelt beskrive bevegelsen i `promptText`, med 1 til 1 000 UTF-16-kodeenheter. |

For en forespørsel kun med tekst bruker du [Opprett en Runway-oppgave for text-to-video](./generate-a-video-from-text).

## Oppgi det første bildet

Sett `promptImage` til en tilgjengelig HTTPS-bilde-URL eller en Base64-bildedata-URI.
Du kan også oppgi en matrise med ett element som inneholder `uri` og `position: "first"`.
Dette grensesnittet godtar én startramme; ikke legg til en oppføring for siste ramme.

HTTPS-bilder må være direkte tilgjengelige uten omdirigeringer og ha gyldige
innholdshoder for bilder. Kodede bildedata-URI-er kan være opptil 5 MB. Se
[Krav til Runway-medieinndata](https://docs.dev.runwayml.com/assets/inputs/)
for bildeformater og dimensjoner.

## Angi varighet og dimensjoner

Bruk en heltallsverdi for `duration` fra `2` til og med `10` sekunder. Det er påkrevd
for `gen4.5` og valgfritt for `gen4_turbo`.

Sett `ratio` til `1280:720`, `720:1280`, `1104:832`, `960:960`, `832:1104` eller
`1584:672`. Dette er bredde- og høydeverdier atskilt med kolon.

For et eksplisitt sampling-seed bruker du `1` til og med `4294967295`. Utelatelse eller `0`
velger et tilfeldig seed. Hvis du inkluderer `contentModeration`, må den tilhørende
`publicFigureThreshold` settes til `auto` eller `low`; ellers utelater du objektet.

## Velg et utdataformat

`gen4.5` godtar `outputFormat` for MP4, ProRes, PNG-sekvenser og HDR-
formatene som er oppført i forespørselsskjemaet. Utelat feltet for H.264 MP4.
`proresProfile` gjelder bare for `prores` og `hdr_prores`; de tillatte verdiene
avhenger av det valgte formatet. Utelat begge feltene med `gen4_turbo`.

## Hent resultatet

Lagre den returnerte `id` og bruk [Hent en Runway-oppgave](./runway-to-get-task-details).
Når `status` er `SUCCEEDED`, leser du resultat-URL-ene i `output`.


## OpenAPI

````yaml api/openapi/video/runway/official-format/post-runway-images-raw-video.openapi.json POST /runwayml/v1/image_to_video
openapi: 3.1.0
info:
  title: Create a Runway image-to-video task
  version: 1.0.0
  description: Create a Runway image-to-video task through CometAPI.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /runwayml/v1/image_to_video:
    post:
      summary: Create a Runway image-to-video task
      description: >-
        Submit a JSON request and save the returned id. Use GET
        /runwayml/v1/tasks/{id} to retrieve the result.
      operationId: runway_images_raw_video
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - title: gen4.5
                  type: object
                  properties:
                    model:
                      type: string
                      description: Model ID for this request variant.
                      const: gen4.5
                      enum:
                        - gen4.5
                    promptText:
                      description: >-
                        Describe the requested scene or motion in 1 to 1,000
                        UTF-16 code units.
                      type: string
                      minLength: 1
                      maxLength: 1000
                    promptImage:
                      description: >-
                        Image to use as the first frame. Supply a media URI or a
                        one-item array with position set to first.
                      oneOf:
                        - description: >-
                            Source image as a public HTTPS URL or a Base64 image
                            data URI.
                          oneOf:
                            - type: string
                              description: >-
                                Public HTTPS image URL. The server must allow
                                HEAD and GET without redirects.
                              pattern: ^https://
                              maxLength: 2048
                            - type: string
                              description: >-
                                Base64 image data URI, including its media type.
                                Maximum encoded length: 5 MB.
                              pattern: ^data:image/[^;]+;base64,
                              maxLength: 5242880
                        - type: array
                          title: First-frame array
                          minItems: 1
                          maxItems: 1
                          items:
                            type: object
                            properties:
                              uri:
                                description: >-
                                  Source image as a public HTTPS URL or a Base64
                                  image data URI.
                                oneOf:
                                  - type: string
                                    description: >-
                                      Public HTTPS image URL. The server must
                                      allow HEAD and GET without redirects.
                                    pattern: ^https://
                                    maxLength: 2048
                                  - type: string
                                    description: >-
                                      Base64 image data URI, including its media
                                      type. Maximum encoded length: 5 MB.
                                    pattern: ^data:image/[^;]+;base64,
                                    maxLength: 5242880
                              position:
                                type: string
                                description: >-
                                  Frame position. Only the first frame is
                                  supported.
                                enum:
                                  - first
                            required:
                              - uri
                              - position
                            additionalProperties: false
                    seed:
                      type: integer
                      minimum: 0
                      maximum: 4294967295
                      description: >-
                        Optional sampling seed. Use a positive integer for an
                        explicit seed. Omission or 0 selects a random seed.
                    ratio:
                      description: >-
                        Requested output dimensions, expressed as width:height.
                        Choose a value listed for this model and endpoint.
                      type: string
                      enum:
                        - '1280:720'
                        - '720:1280'
                        - '1104:832'
                        - '960:960'
                        - '832:1104'
                        - '1584:672'
                    duration:
                      description: >-
                        Requested video duration in whole seconds, from 2
                        through 10.
                      type: integer
                      minimum: 2
                      maximum: 10
                    contentModeration:
                      type: object
                      description: >-
                        Optional content moderation settings. Omit the object to
                        use standard moderation.
                      properties:
                        publicFigureThreshold:
                          type: string
                          description: >-
                            Use auto for standard moderation or low for less
                            restrictive public-figure filtering.
                          enum:
                            - auto
                            - low
                      required:
                        - publicFigureThreshold
                      additionalProperties: false
                    outputFormat:
                      description: >-
                        Output encoding. Omit for mp4 (H.264). prores returns
                        MOV; png_sequence returns a PNG ZIP; sdr_rec709_10bit
                        returns 10-bit Rec.709 HEVC. hdr10 and hlg return 10-bit
                        HDR MP4; hdr_pq_12bit_master returns 12-bit HEVC MOV;
                        hdr_prores returns HDR ProRes MOV. The HDR PNG/EXR
                        sequence formats return ZIP archives; the ACEScg
                        variants target the named ACES version.
                      type: string
                      enum:
                        - mp4
                        - prores
                        - png_sequence
                        - hdr10
                        - hlg
                        - sdr_rec709_10bit
                        - hdr_pq_12bit_master
                        - hdr_prores
                        - hdr_png_sequence
                        - hdr_exr_sequence
                        - hdr_exr_acescg_sequence_1_3
                        - hdr_exr_acescg_sequence_2_0
                    proresProfile:
                      description: >-
                        Profile for outputFormat prores or hdr_prores. Omit for
                        4444 with prores, or 422 HQ with hdr_prores. hdr_prores
                        accepts only 422, 422 HQ, or 4444. Omit this field for
                        other formats.
                      type: string
                      enum:
                        - '422'
                        - '4444'
                        - 422 Proxy
                        - 422 LT
                        - 422 HQ
                        - 4444 XQ
                  required:
                    - promptText
                    - promptImage
                    - ratio
                    - duration
                    - model
                  allOf:
                    - if:
                        required:
                          - proresProfile
                      then:
                        required:
                          - outputFormat
                        properties:
                          outputFormat:
                            type: string
                            description: Output format when proresProfile is supplied.
                            enum:
                              - prores
                              - hdr_prores
                    - if:
                        required:
                          - outputFormat
                        properties:
                          outputFormat:
                            const: hdr_prores
                            description: HDR ProRes output.
                      then:
                        properties:
                          proresProfile:
                            type: string
                            description: Profile supported by HDR ProRes.
                            enum:
                              - '422'
                              - 422 HQ
                              - '4444'
                  additionalProperties: false
                  description: Request parameters for gen4.5.
                - title: gen4_turbo
                  type: object
                  properties:
                    model:
                      type: string
                      description: Model ID for this request variant.
                      const: gen4_turbo
                      enum:
                        - gen4_turbo
                    promptImage:
                      description: >-
                        Image to use as the first frame. Supply a media URI or a
                        one-item array with position set to first.
                      oneOf:
                        - description: >-
                            Source image as a public HTTPS URL or a Base64 image
                            data URI.
                          oneOf:
                            - type: string
                              description: >-
                                Public HTTPS image URL. The server must allow
                                HEAD and GET without redirects.
                              pattern: ^https://
                              maxLength: 2048
                            - type: string
                              description: >-
                                Base64 image data URI, including its media type.
                                Maximum encoded length: 5 MB.
                              pattern: ^data:image/[^;]+;base64,
                              maxLength: 5242880
                        - type: array
                          title: First-frame array
                          minItems: 1
                          maxItems: 1
                          items:
                            type: object
                            properties:
                              uri:
                                description: >-
                                  Source image as a public HTTPS URL or a Base64
                                  image data URI.
                                oneOf:
                                  - type: string
                                    description: >-
                                      Public HTTPS image URL. The server must
                                      allow HEAD and GET without redirects.
                                    pattern: ^https://
                                    maxLength: 2048
                                  - type: string
                                    description: >-
                                      Base64 image data URI, including its media
                                      type. Maximum encoded length: 5 MB.
                                    pattern: ^data:image/[^;]+;base64,
                                    maxLength: 5242880
                              position:
                                type: string
                                description: >-
                                  Frame position. Only the first frame is
                                  supported.
                                enum:
                                  - first
                            required:
                              - uri
                              - position
                            additionalProperties: false
                    seed:
                      type: integer
                      minimum: 0
                      maximum: 4294967295
                      description: >-
                        Optional sampling seed. Use a positive integer for an
                        explicit seed. Omission or 0 selects a random seed.
                    ratio:
                      description: >-
                        Requested output dimensions, expressed as width:height.
                        Choose a value listed for this model and endpoint.
                      type: string
                      enum:
                        - '1280:720'
                        - '720:1280'
                        - '1104:832'
                        - '832:1104'
                        - '960:960'
                        - '1584:672'
                    duration:
                      description: >-
                        Requested video duration in whole seconds, from 2
                        through 10.
                      type: integer
                      minimum: 2
                      maximum: 10
                    contentModeration:
                      type: object
                      description: >-
                        Optional content moderation settings. Omit the object to
                        use standard moderation.
                      properties:
                        publicFigureThreshold:
                          type: string
                          description: >-
                            Use auto for standard moderation or low for less
                            restrictive public-figure filtering.
                          enum:
                            - auto
                            - low
                      required:
                        - publicFigureThreshold
                      additionalProperties: false
                    promptText:
                      description: >-
                        Optional motion prompt, from 1 to 1,000 UTF-16 code
                        units.
                      type: string
                      minLength: 1
                      maxLength: 1000
                  required:
                    - promptImage
                    - ratio
                    - model
                  additionalProperties: false
                  description: Request parameters for gen4_turbo.
              discriminator:
                propertyName: model
            examples:
              Gen-4.5:
                summary: Gen-4.5
                value:
                  model: gen4.5
                  promptImage: >-
                    https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg
                  promptText: The cat turns toward the camera.
                  ratio: '1280:720'
                  duration: 5
              Gen-4 Turbo:
                summary: Gen-4 Turbo
                value:
                  model: gen4_turbo
                  promptImage: >-
                    https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg
                  ratio: '1280:720'
                  duration: 5
                  promptText: The cat turns toward the camera.
              First-frame array:
                summary: First-frame array
                value:
                  model: gen4.5
                  promptImage:
                    - uri: >-
                        https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg
                      position: first
                  promptText: The cat turns toward the camera.
                  ratio: '1280:720'
                  duration: 5
      responses:
        '200':
          description: Task submitted. Save its id to retrieve task status.
          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-000000000001
        '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
          label: Gen-4.5
          source: |
            curl "https://api.cometapi.com/runwayml/v1/image_to_video" \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "gen4.5",
              "promptImage": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg",
              "promptText": "The cat turns toward the camera.",
              "ratio": "1280:720",
              "duration": 5
            }'
        - lang: Python
          label: Gen-4.5
          source: |
            import os
            import requests

            payload = {'model': 'gen4.5',
             'promptImage': 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg',
             'promptText': 'The cat turns toward the camera.',
             'ratio': '1280:720',
             'duration': 5}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/image_to_video",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
                timeout=60,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: Gen-4.5
          source: |
            const payload = {
              "model": "gen4.5",
              "promptImage": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg",
              "promptText": "The cat turns toward the camera.",
              "ratio": "1280:720",
              "duration": 5
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/image_to_video",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(payload),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            console.log((await response.json()).id);
        - lang: Shell
          label: Gen-4 Turbo
          source: |
            curl "https://api.cometapi.com/runwayml/v1/image_to_video" \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "gen4_turbo",
              "promptText": "The cat turns toward the camera.",
              "promptImage": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg",
              "ratio": "1280:720",
              "duration": 5
            }'
        - lang: Python
          label: Gen-4 Turbo
          source: |
            import os
            import requests

            payload = {'model': 'gen4_turbo',
             'promptText': 'The cat turns toward the camera.',
             'promptImage': 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg',
             'ratio': '1280:720',
             'duration': 5}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/image_to_video",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
                timeout=60,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: Gen-4 Turbo
          source: |
            const payload = {
              "model": "gen4_turbo",
              "promptText": "The cat turns toward the camera.",
              "promptImage": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg",
              "ratio": "1280:720",
              "duration": 5
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/image_to_video",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(payload),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            console.log((await response.json()).id);
        - lang: Shell
          label: First-frame array
          source: |
            curl "https://api.cometapi.com/runwayml/v1/image_to_video" \
              --request POST \
              --header "Authorization: Bearer $COMETAPI_KEY" \
              --header "Content-Type: application/json" \
              --data '{
              "model": "gen4.5",
              "promptImage": [
                {
                  "uri": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg",
                  "position": "first"
                }
              ],
              "promptText": "The cat turns toward the camera.",
              "ratio": "1280:720",
              "duration": 5
            }'
        - lang: Python
          label: First-frame array
          source: |
            import os
            import requests

            payload = {'model': 'gen4.5',
             'promptImage': [{'uri': 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg',
                              'position': 'first'}],
             'promptText': 'The cat turns toward the camera.',
             'ratio': '1280:720',
             'duration': 5}

            response = requests.post(
                "https://api.cometapi.com/runwayml/v1/image_to_video",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json=payload,
                timeout=60,
            )
            response.raise_for_status()
            print(response.json()["id"])
        - lang: JavaScript
          label: First-frame array
          source: |
            const payload = {
              "model": "gen4.5",
              "promptImage": [
                {
                  "uri": "https://upload.wikimedia.org/wikipedia/commons/3/3a/Cat03.jpg",
                  "position": "first"
                }
              ],
              "promptText": "The cat turns toward the camera.",
              "ratio": "1280:720",
              "duration": 5
            };

            const response = await fetch(
              "https://api.cometapi.com/runwayml/v1/image_to_video",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify(payload),
              },
            );
            if (!response.ok) throw new Error(await response.text());
            console.log((await response.json()).id);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use your CometAPI API key.

````