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

> ## Agent Instructions
> Send API requests to https://api.ttapi.io with the TT-API-KEY header. Midjourney account hosting uses https://hold.ttapi.io. Claude Code uses https://cc.ttapi.io.
> Most generation endpoints are asynchronous. The submit response returns a job id. Poll that product's fetch endpoint, or pass a webhook on the submit request. A fetch call does not start a new generation.
> 1 USD = 100 quota. Check the pricing page for that product before estimating cost.
> This file lists the English docs. Follow every /_llms/ link recursively for the API reference, Chinese, and Russian. Open a page's .md URL for the endpoint schema.

# 关键帧生视频

> 关键帧生视频 - 通过 keyframes 在视频中间指定关键帧图像，可与首帧和尾帧组合使用

这是 **Grok 视频 API** 的关键帧生视频接口。通过 `keyframes` 在视频中间指定关键帧图像，模型会在关键帧之间生成过渡画面。可与 `first_frame`（首帧）和 `last_frame`（尾帧）组合使用，支持以下组合方式：

* **首帧 + 关键帧**：指定视频开头和中间关键帧
* **关键帧 + 尾帧**：指定中间关键帧和视频结尾
* **首帧 + 关键帧 + 尾帧**：完整控制视频的首帧、中间关键帧和尾帧

支持 `grok-imagine-video-1.5-fast` 和 `grok-imagine-video-1.5`。

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

<Callout type="info">
  **关键帧限制**：每个请求最多 4 个关键帧；`timestamp_s` 必须大于 0 且小于视频时长；关键帧之间至少间隔 1/3 秒。
</Callout>


## OpenAPI

````yaml openapi/cn/grok-keyframe-to-video.json POST /grok/generations
openapi: 3.1.0
info:
  title: Grok Video - 关键帧生视频 DOCS
  version: 1.0.0
  description: >-
    Grok 关键帧生视频 API - 通过 keyframes
    在视频中间指定关键帧图像，可与首帧（first_frame）和尾帧（last_frame）组合使用。
servers:
  - url: https://api.ttapi.io
security: []
paths:
  /grok/generations:
    post:
      description: 关键帧生视频 - 通过 keyframes 在视频中间指定关键帧图像，可与首帧和尾帧组合使用
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KeyframeToVideoRequest'
            example:
              prompt: <string>
              model: grok-imagine-video-1.5-fast
              aspect_ratio: '16:9'
              video_length: '10'
              resolution_name: 720p
              first_frame: https://example.com/first_frame.jpg
              keyframes:
                - image:
                    url: https://example.com/keyframe1.jpg
                  timestamp_s: 3
                - image:
                    url: https://example.com/keyframe2.jpg
                  timestamp_s: 6
              last_frame: https://example.com/last_frame.jpg
              hook_url: https://example.com/callback
      responses:
        '200':
          $ref: '#/components/responses/SuccessResponse'
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    KeyframeToVideoRequest:
      type: object
      description: 关键帧生视频请求参数
      properties:
        prompt:
          type: string
          description: 提示词，用于引导关键帧之间的运动和镜头。可选。
        model:
          type: string
          description: 模型名称。
          enum:
            - grok-imagine-video-1.5-fast
            - grok-imagine-video-1.5
          default: grok-imagine-video-1.5-fast
          example: grok-imagine-video-1.5-fast
        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: >-
            视频时长（秒）。`grok-imagine-video-1.5-fast` 取值范围为 6 到 30（6 秒、10 秒为标准时长；不支持
            7 秒和 11 秒）；`grok-imagine-video-1.5` 取值范围为 1 到 15。
        resolution_name:
          type: string
          default: 720p
          enum:
            - 480p
            - 720p
            - 1080p
          description: 输出分辨率。可选 480p、720p。
        first_frame:
          type: string
          description: 首帧图片地址。用于严格指定视频的第一帧。可与 keyframes 和 last_frame 组合使用。
        keyframes:
          type: array
          description: >-
            关键帧数组。每个元素包含一个图片地址和对应的时间戳（秒）。最多 4 个关键帧。`timestamp_s` 必须大于 0
            且小于视频时长，关键帧之间至少间隔 1/3 秒。
          maxItems: 4
          items:
            type: object
            properties:
              image:
                type: object
                description: 关键帧图片
                properties:
                  url:
                    type: string
                    description: 关键帧图片地址
                required:
                  - url
              timestamp_s:
                type: number
                description: 关键帧时间戳（秒），必须大于 0 且小于视频时长
            required:
              - image
              - timestamp_s
        last_frame:
          type: string
          description: >-
            尾帧图片地址。用于严格指定视频的最后一帧。可与 keyframes 和 first_frame 组合使用。当 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
        - keyframes
  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 密钥。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.