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

# 首尾帧生视频

> 首尾帧生视频 - 同时传入 first_frame 和 last_frame，严格指定视频首帧和尾帧

这是 **Grok 视频 API** 的首尾帧生视频接口。同时传入 `first_frame` 和 `last_frame`，严格指定视频的首帧和尾帧图像。仅 `grok-imagine-video-1.5-fast` 支持。当首尾帧传入同一张图片时，可实现循环效果（loop）。

<Callout type="warning">
  **注意**：不允许 NSFW 内容。单次或偶尔的审核失败不会产生任何费用，但反复触发审核失败可能会产生扣费。
</Callout>


## OpenAPI

````yaml openapi/cn/grok-first-last-frame-to-video.json POST /grok/generations
openapi: 3.1.0
info:
  title: Grok Video - 首尾帧生视频 DOCS
  version: 1.0.0
  description: Grok 首尾帧生视频 API - 同时传入 first_frame 和 last_frame，严格指定视频的首帧和尾帧图像。
servers:
  - url: https://api.ttapi.io
security: []
paths:
  /grok/generations:
    post:
      description: 首尾帧生视频 - 同时传入 first_frame 和 last_frame，严格指定视频首帧和尾帧
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FirstLastFrameToVideoRequest'
      responses:
        '200':
          $ref: '#/components/responses/SuccessResponse'
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    FirstLastFrameToVideoRequest:
      type: object
      description: 首尾帧生视频请求参数
      properties:
        model:
          type: string
          description: >-
            模型名称。仅支持 `grok-imagine-video-1.5-fast`：时长 6-30 秒（6 秒、10 秒为标准时长；不支持 7
            秒和 11 秒）；支持多张垫图（最多 7 张）；支持首尾帧控制。
          enum:
            - grok-imagine-video-1.5-fast
          default: grok-imagine-video-1.5-fast
          example: grok-imagine-video-1.5-fast
        prompt:
          type: string
          description: 提示词，支持较长文本输入。
        aspect_ratio:
          type: string
          default: '16:9'
          enum:
            - '2:3'
            - '3:2'
            - '1:1'
            - '9:16'
            - '16:9'
          description: 视频宽高比
        video_length:
          type: string
          default: '10'
          description: 视频时长（秒）。取值范围 6 到 30，其中 6 秒和 10 秒为标准时长。
        resolution_name:
          type: string
          default: 720p
          enum:
            - 480p
            - 720p
            - 1080p
          description: 输出分辨率。可选 480p、720p。
        first_frame:
          type: string
          description: 首帧图片地址。仅 `grok-imagine-video-1.5-fast` 支持。用于严格指定视频的第一帧。
        last_frame:
          type: string
          description: >-
            尾帧图片地址。仅 `grok-imagine-video-1.5-fast` 支持。用于严格指定视频的最后一帧。当
            `first_frame` 和 `last_frame` 传入同一张图片时，实现循环效果（loop）。
        hook_url:
          type: string
          description: >-
            回调地址，任务完成或失败将通过请地址进行通知，通知数据结构与<a href="fetch"
            target="_self">fetch结构</a>一致。如果未设置，则需要请求<a href="fetch"
            target="_self">fetch接口</a>进行查询
          example: https://example.com/callback
      required:
        - prompt
        - first_frame
        - last_frame
  responses:
    SuccessResponse:
      description: 请求成功
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: SUCCESS
              message:
                type: string
                example: success
              data:
                type: object
                example:
                  jobId: jobId
            required:
              - status
              - message
              - data
    400Response:
      description: 参数错误
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: '"prompt" cannot be empty.'
              data:
                type: object
            required:
              - status
              - message
    401Response:
      description: 授权失败
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: Wrong TT-API-KEY or email is not activated.
            required:
              - status
              - message
  securitySchemes:
    CustomApiKey:
      type: apiKey
      in: header
      name: TT-API-KEY
      description: >-
        请前往 <a href='https://dashboard.ttapi.io' target='_blank'>TTAPI 控制台</a>
        获取 API 密钥。

````