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

# Grok Video

> xAI video generation API for text-to-video and image-to-video workflows

## Overview

Grok Video is an xAI video model for text-to-video generation and image-to-video workflows. Use this page when you are ready to call the API after trying the model in the APIXO playground.

| Capability             | Value                                                                    |
| ---------------------- | ------------------------------------------------------------------------ |
| Model ID               | `grok-video`                                                             |
| Modes                  | `text-to-video`, `image-to-video`                                        |
| Prompt length          | 1-5000 characters                                                        |
| Duration               | 6-30 seconds                                                             |
| Resolutions            | `480p`, `720p`                                                           |
| Aspect ratios          | `1:1`, `3:2`, `2:3`, `16:9`, `9:16`                                      |
| Image-to-video sources | 1 image URL, or a completed `grok-image` task with `task_id` and `index` |
| Output                 | MP4 video URL in `resultJson.resultUrls`                                 |

## Endpoint and authentication

Base URL:

```text theme={null}
https://api.apixo.ai/api/v1
```

| Method | Endpoint                                 | Purpose                               |
| ------ | ---------------------------------------- | ------------------------------------- |
| `POST` | `/generateTask/grok-video`               | Submit a generation task              |
| `GET`  | `/statusTask/grok-video?taskId={taskId}` | Poll task status and retrieve results |

All requests require your APIXO API key:

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

Submit requests also require:

```http theme={null}
Content-Type: application/json
```

## Copy-paste async quickstart

This minimal request submits a text-to-video task and returns a `taskId`.

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/grok-video" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a peaceful lakeside at sunset with gentle waves",
      "duration": 6,
      "resolution": "480p",
      "aspect_ratio": "3:2",
      "style": "normal"
    }
  }'
```

Successful response:

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

Save the `taskId`; you need it to poll for the final result.

## Poll for result

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/grok-video?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Processing response:

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

Success response:

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/xxx.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965655929,
    "costTime": 45000
  }
}
```

Failed response:

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content violates provider policy, please adjust the prompt",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

Parse `resultJson` after `state` becomes `success`:

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;
```

## Request body

### Text-to-video

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-video",
    "prompt": "a cinematic city street after rain, soft reflections, slow camera push",
    "duration": 6,
    "resolution": "480p",
    "aspect_ratio": "3:2",
    "style": "normal"
  }
}
```

### Image-to-video with an image URL

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "make this scene into a short cinematic pan",
    "image_urls": [
      "https://example.com/ref.jpg"
    ],
    "duration": 10,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "style": "fun"
  }
}
```

### Image-to-video from a Grok Image task

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "turn this character into a walking animation",
    "task_id": "task_previous_grok_image",
    "index": 0,
    "duration": 10,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "style": "spicy"
  }
}
```

## Parameters

<ParamField body="request_type" type="string" default="async">
  Result delivery mode. Omit this field or use `async` for polling with `statusTask`, or use `callback` for webhook delivery.
</ParamField>

<ParamField body="callback_url" type="string">
  Required when `request_type` is `callback`. Provide a public HTTPS URL that can receive the final task payload. See [Webhooks](/api-reference/webhooks).
</ParamField>

<ParamField body="input" type="object" required>
  Grok Video input parameters.

  <Expandable title="properties">
    <ParamField body="mode" type="string" required>
      Generation mode. Supported values: `text-to-video`, `image-to-video`.
    </ParamField>

    <ParamField body="prompt" type="string" required>
      Text prompt describing the desired video. Supports 1-5000 characters. Empty prompts are rejected.
    </ParamField>

    <ParamField body="duration" type="integer|string" required>
      Output duration in seconds. Supports integers from `6` through `30`. Numeric strings such as `"10"` are accepted and normalized before billing.
    </ParamField>

    <ParamField body="resolution" type="string" required>
      Output resolution. Supported values: `480p`, `720p`. Values are trimmed and normalized to lowercase.
    </ParamField>

    <ParamField body="aspect_ratio" type="string">
      Output aspect ratio. Supported values: `1:1`, `3:2`, `2:3`, `16:9`, `9:16`. If omitted, `text-to-video` uses `3:2` and `image-to-video` uses `16:9`.
    </ParamField>

    <ParamField body="style" type="string" default="normal">
      Motion style. Supported values: `fun`, `normal`, `spicy`. The provider manual positions `spicy` for task continuation or recreation workflows.
    </ParamField>

    <ParamField body="image_urls" type="string[]">
      Reference image URLs for the direct `image-to-video` method. Supports at most 1 public, non-empty URL. Do not combine this with the `task_id` + `index` method.
    </ParamField>

    <ParamField body="task_id" type="string">
      APIXO task ID from a completed `grok-image` task. Use with `index` for `image-to-video` task continuation. The task must exist and must have completed successfully.
    </ParamField>

    <ParamField body="index" type="integer">
      Result index from the completed `grok-image` task. Required with `task_id`. Supported range: `0` through `5`.
    </ParamField>
  </Expandable>
</ParamField>

## Response format

### Submit task response

`POST /generateTask/grok-video` returns a task ID when the task is accepted:

<ResponseField name="code" type="integer">
  API status code. `200` means the task was accepted.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable status message.
</ResponseField>

<ResponseField name="data.taskId" type="string">
  Unique task identifier used with the status endpoint.
</ResponseField>

### Status response fields

<ResponseField name="taskId" type="string">
  Unique task identifier.
</ResponseField>

<ResponseField name="state" type="string">
  Current task state: `processing`, `success`, or `failed`.
</ResponseField>

<ResponseField name="resultJson" type="string">
  JSON string containing the generated video URLs in `resultUrls`. Present when `state` is `success`.
</ResponseField>

<ResponseField name="failCode" type="string">
  Machine-readable failure code. Present when `state` is `failed`.
</ResponseField>

<ResponseField name="failMsg" type="string">
  Human-readable failure message. Present when `state` is `failed`.
</ResponseField>

<ResponseField name="createTime" type="integer">
  Task creation timestamp in Unix milliseconds.
</ResponseField>

<ResponseField name="completeTime" type="integer">
  Task completion timestamp in Unix milliseconds. Present after completion.
</ResponseField>

<ResponseField name="costTime" type="integer">
  Processing duration in milliseconds. Present after completion.
</ResponseField>

## Webhook callback mode

Use callback mode when your backend should receive the final result automatically instead of polling.

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/grok-video" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "text-to-video",
      "prompt": "a clean product reveal video with a slow camera push-in",
      "duration": 6,
      "resolution": "480p",
      "aspect_ratio": "3:2",
      "style": "normal"
    }
  }'
```

Callback delivery uses the same final payload shape as the status response. See [Webhooks](/api-reference/webhooks) for delivery requirements and retry behavior.

## Billing

Grok Video is billed per second. The selected `resolution` determines the per-second unit price, and the submitted `duration` determines the billable seconds.

| Resolution | APIXO price       | Minimum valid request cost |
| ---------- | ----------------- | -------------------------- |
| `480p`     | `$0.015 / second` | `$0.09` for 6 seconds      |
| `720p`     | `$0.03 / second`  | `$0.18` for 6 seconds      |

Formula:

```text theme={null}
total cost = duration * resolution unit price
```

For current route and market comparison pricing, see [Pricing](https://apixo.ai/pricing).

## Latency and polling

The user manual lists typical Grok Video generation time at about 40s-60s. Actual latency may vary by prompt complexity, duration, resolution, provider queue load, and storage transfer time.

| Workload                       | Typical generation time | Recommended first poll  | Poll interval |
| ------------------------------ | ----------------------- | ----------------------- | ------------- |
| `480p` or `720p`, 6-30 seconds | About 40s-60s           | 30s after task creation | 5s            |

<Tip>
  For production workloads, use callback mode to avoid frequent polling while video tasks run.
</Tip>

Result URLs are valid for 15 days. Download and store important outputs promptly.

For image-to-video, use exactly one source method: either `image_urls`, or `task_id` with `index`. Public image URLs should point directly to JPG, PNG, or WebP files and should be accessible by APIXO.

Prompts can be written in English or Chinese. More specific camera motion, scene timing, subject action, lighting, and style details usually produce better results.

Rate limits and concurrency can vary by account, API key, and route. If you receive `429`, slow down requests and retry with backoff. For account-level details, see [System APIs](/api-reference/system).

## Errors and troubleshooting

### HTTP errors

| Code  | Meaning                                                                                                                                                 | What to do                                             |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| `400` | Invalid request body, missing `mode`, missing `prompt`, invalid `duration`, invalid `resolution`, malformed image input, or invalid `task_id` / `index` | Fix the request before retrying                        |
| `401` | Missing or invalid API key                                                                                                                              | Check the `Authorization` header                       |
| `402` | Insufficient balance or quota                                                                                                                           | Add balance or switch account/key                      |
| `404` | Task not found when polling                                                                                                                             | Check the `taskId`                                     |
| `429` | Rate limit or concurrency limit reached                                                                                                                 | Retry with exponential backoff                         |
| `500` | Internal error or unknown task failure                                                                                                                  | Retry with backoff or contact support if it persists   |
| `502` | Upstream provider or network error                                                                                                                      | Retry with backoff                                     |
| `503` | Service temporarily unavailable                                                                                                                         | Retry later                                            |
| `504` | Upstream timeout                                                                                                                                        | Retry later or use callback mode for long-running jobs |

### Validation notes

| Parameter            | Backend behavior                                                                                                                                    |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `input.mode`         | Required for routing. Must be `text-to-video` or `image-to-video`.                                                                                  |
| `input.prompt`       | Required string. Must not be empty and must not exceed 5000 characters.                                                                             |
| `input.duration`     | Required. Accepts an integer or an integer string. Must resolve to a value from `6` through `30`.                                                   |
| `input.resolution`   | Required string. `480p` and `720p` are accepted after trimming and lowercasing.                                                                     |
| `input.aspect_ratio` | Optional. Must be one of `1:1`, `3:2`, `2:3`, `16:9`, `9:16` when provided. Defaults are `3:2` for `text-to-video` and `16:9` for `image-to-video`. |
| `input.image_urls`   | For `image-to-video`, one accepted source method. Must be an array of non-empty strings and cannot contain more than 1 URL.                         |
| `input.task_id`      | For `image-to-video`, the alternate source method. Must be an existing completed APIXO `grok-image` task.                                           |
| `input.index`        | Required with `task_id`. Must be an integer from `0` through `5`.                                                                                   |
| `input.style`        | Optional. Must be `fun`, `normal`, or `spicy`; defaults to `normal` when omitted.                                                                   |

### Task failure codes

`failCode` is generated from APIXO's mapped provider error. Common values include:

| Fail code              | Meaning                                                      | What to do                                              |
| ---------------------- | ------------------------------------------------------------ | ------------------------------------------------------- |
| `SensitiveContent`     | Prompt or input/output content was rejected by safety checks | Change the prompt or reference image                    |
| `PromptInvalid`        | Prompt was invalid or rejected by the provider               | Rewrite the prompt and retry                            |
| `ImageFormatIncorrect` | Reference image format could not be processed                | Use a public, direct image URL in a common image format |
| `RateLimited`          | Provider rate limit was reached                              | Retry with exponential backoff                          |
| `Timeout`              | Provider timeout                                             | Retry later or use callback mode                        |
| `InternalError`        | Provider or APIXO service was temporarily unavailable        | Retry later                                             |
| `Unknown error`        | Provider returned an unmapped failure                        | Retry with backoff or contact support with the `taskId` |

See [Error Codes](/api-reference/errors) for the full error reference.

## Related links

* [Generation API Overview](/models)
* [Generate Task](/api-reference/generate-task)
* [Status Task](/api-reference/status-task)
* [Webhooks](/api-reference/webhooks)
* [Error Codes](/api-reference/errors)
* [Parameter Specification](/api-reference/parameters)
* [Routing Strategies](/concepts/routing-strategies)
* [Pricing](https://apixo.ai/pricing)
