MixMedia API
RUEN
Sign inGet started
Open as Markdown
← Try it on the website

Grok Imagine

xAI · ~1.5 min
from $0.06per second

xAI video up to 15 seconds from a description or a photo; it can also change your video.

Grok Imagine is an xAI video model. It films 1 to 15 second clips in 480p and 720p from a description or your photos (up to 7), and changes a finished clip from a description: style, clothes, background. For editing use a clip up to 8 seconds — the result has the same length.

You pay per second of the clip; when editing, per second of the source clip.

One model, grok-imagine · ~1.5 min. The result follows the input fields (prompt, frames, references, video_mode, duration) — there are no separate «animate / edit» endpoints.

Features

  • nsfw_check — check before charge
  • Clip edit via video_urls (up to 8 s)

Price

ResolutionPrice per second
480p$0.06
720p$0.084
  • Price = per-second price × clip length, rounded up to $0.001. Charged when the task is created and fully refunded if it fails.
  • Each attached photo adds $0.0024.
  • With an uploaded video: $0.096 per second of the source clip (up to 8 s); the result has the same length. resolution, aspect_ratio and duration are not needed — they come from the clip.

Media limits

TypeLimits
Imagesup to 7; JPG / PNG / WebP; upload via files/upload — up to 30 MB per file
Videosup to 1; total ≤ 8 s (each clip 2…8 s); MP4 / MOV → MP4 on the server; upload ≤ 200 MB

Photos — public https or upload; video and audio — files/upload only.

How the task is shaped

FieldsMode
prompt onlytext → video
image_urlsphotos → video (up to 7)
video_urlsedit clip (up to 8 s); resolution / aspect_ratio / duration come from the clip

Upstream rejects aspect_ratio «auto» — text defaults to 16:9; with a photo the frame follows the photo.

Parameters (field input)

ParameterDescriptionValues (default in bold)
promptWhat happens in the clip: scene, motion, camera, light, styletext, up to 8000 chars
image_urlsYour photos (https): a single photo becomes the first frame["https://…"], up to 7
video_urlsYour videos (MP4): upload them via files/upload first and pass the returned links["https://…"], up to 1
resolutionVideo resolution480p · 720p
aspect_ratioAspect ratio16:9 · 9:16 · 1:1 · 4:3 · 3:4 · 3:2 · 2:3
durationVideo duration in seconds1 to 15 (default 8)
nsfw_checkContent check: the description and photos are checked first; if not allowed, no task is created and nothing is chargedtrue false (default false)
trim_video_toTrim each of your clips to N seconds: the beginning stays. Shorter clips are not changedwhole number, 2 to 8
auto_trimIf your clips together are longer than 8 s, trim them instead of returning an error (the longest first)true false (default false)

Examples

Prompt only

curl -X POST https://mixmedia.tech/api/v1/jobs/createTask \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"grok-imagine","input":{"prompt":"A drone flies over an autumn forest at sunrise, fog, cinematic","resolution":"480p","aspect_ratio":"16:9","duration":"8"}}'
import os, requests

r = requests.post(
    "https://mixmedia.tech/api/v1/jobs/createTask",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
      "model": "grok-imagine",
      "input": {
        "prompt": "A drone flies over an autumn forest at sunrise, fog, cinematic",
        "resolution": "480p",
        "aspect_ratio": "16:9",
        "duration": "8"
      }
    },
)
print(r.json())  # {"code": 200, "data": {"taskId": "..."}}
const r = await fetch("https://mixmedia.tech/api/v1/jobs/createTask", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "grok-imagine",
    "input": {
      "prompt": "A drone flies over an autumn forest at sunrise, fog, cinematic",
      "resolution": "480p",
      "aspect_ratio": "16:9",
      "duration": "8"
    }
  }),
});
console.log(await r.json()); // { code: 200, data: { taskId: "..." } }

With a first frame

curl -X POST https://mixmedia.tech/api/v1/jobs/createTask \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"grok-imagine","input":{"prompt":"The character slowly turns to the camera, the wind moves the hair","image_urls":["https://mixmedia.tech/static/img/previews/gpt-t2i.jpg"],"resolution":"480p","duration":"8"}}'
import os, requests

r = requests.post(
    "https://mixmedia.tech/api/v1/jobs/createTask",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
      "model": "grok-imagine",
      "input": {
        "prompt": "The character slowly turns to the camera, the wind moves the hair",
        "image_urls": [
          "https://mixmedia.tech/static/img/previews/gpt-t2i.jpg"
        ],
        "resolution": "480p",
        "duration": "8"
      }
    },
)
print(r.json())  # {"code": 200, "data": {"taskId": "..."}}
const r = await fetch("https://mixmedia.tech/api/v1/jobs/createTask", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "grok-imagine",
    "input": {
      "prompt": "The character slowly turns to the camera, the wind moves the hair",
      "image_urls": [
        "https://mixmedia.tech/static/img/previews/gpt-t2i.jpg"
      ],
      "resolution": "480p",
      "duration": "8"
    }
  }),
});
console.log(await r.json()); // { code: 200, data: { taskId: "..." } }

With your video

curl -X POST https://mixmedia.tech/api/v1/jobs/createTask \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"grok-imagine","input":{"prompt":"Make the clip anime style, keep everything else","video_urls":["https://mixmedia.tech/files/<id>.mp4"]}}'
import os, requests

r = requests.post(
    "https://mixmedia.tech/api/v1/jobs/createTask",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
      "model": "grok-imagine",
      "input": {
        "prompt": "Make the clip anime style, keep everything else",
        "video_urls": [
          "https://mixmedia.tech/files/<id>.mp4"
        ]
      }
    },
)
print(r.json())  # {"code": 200, "data": {"taskId": "..."}}
const r = await fetch("https://mixmedia.tech/api/v1/jobs/createTask", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "grok-imagine",
    "input": {
      "prompt": "Make the clip anime style, keep everything else",
      "video_urls": [
        "https://mixmedia.tech/files/<id>.mp4"
      ]
    }
  }),
});
console.log(await r.json()); // { code: 200, data: { taskId: "..." } }

Trim your video

Your clip: up to 8 s. No need to cut a long clip beforehand: auto_trim: true cuts it to 8 s, trim_video_to: N to N s (the beginning stays). Trimming is free; the price uses the trimmed seconds.

curl -X POST https://mixmedia.tech/api/v1/jobs/createTask \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"grok-imagine","input":{"prompt":"Make the clip anime style, keep everything else","video_urls":["https://mixmedia.tech/files/<id>.mp4"],"auto_trim":true}}'
import os, requests

r = requests.post(
    "https://mixmedia.tech/api/v1/jobs/createTask",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
      "model": "grok-imagine",
      "input": {
        "prompt": "Make the clip anime style, keep everything else",
        "video_urls": [
          "https://mixmedia.tech/files/<id>.mp4"
        ],
        "auto_trim": True
      }
    },
)
print(r.json())  # {"code": 200, "data": {"taskId": "..."}}
const r = await fetch("https://mixmedia.tech/api/v1/jobs/createTask", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "grok-imagine",
    "input": {
      "prompt": "Make the clip anime style, keep everything else",
      "video_urls": [
        "https://mixmedia.tech/files/<id>.mp4"
      ],
      "auto_trim": true
    }
  }),
});
console.log(await r.json()); // { code: 200, data: { taskId: "..." } }

One uploaded file: up to 30 s. Without these options, clips that are too long return a 400 error with a hint.

Create and result

  1. POST /api/v1/jobs/createTask with model and input.
  2. Poll GET /api/v1/jobs/recordInfo?taskId=… every 3–5 s (or a callback).

Successful createTask (HTTP 200)

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_...",
    "task_id": "task_...",
    "status": "submitted"
  }
}

Completed task (recordInfo)

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_...",
    "task_id": "task_...",
    "state": "success",
    "status": "completed",
    "costUsd": "0.384",
    "refunded": false,
    "resultJson": {
      "videos": [
        {
          "url": "https://…/out.mp4"
        }
      ],
      "duration": 8
    }
  }
}

Aliases: task_id = taskId; status: pending / processing / completed / failed alongside state. Clip URL is in resultJson. size is an alias of aspect_ratio in input.

Photos can be any public https links or uploads via files/upload. Videos and audio — via files/upload only.

Error handling

API responses are JSON {"code", "msg", "data"}; errors also have a string error field (type). On /api/v1/* the HTTP status matches body code.

Example response bodies

400

{
  "code": 400,
  "msg": "input.duration: must be between 4 and 30, or \"auto\" / -1",
  "data": null,
  "error": "invalid_request_error"
}

401

{
  "code": 401,
  "msg": "Authentication failed. Please check your API key",
  "data": null,
  "error": "authentication_error"
}

402

{
  "code": 402,
  "msg": "Insufficient balance. Please top up and try again. Available: $0.01, required: $0.015. Top up at https://ai.aimixmedia.site/cabinet/billing",
  "data": {
    "balance": "0.0100",
    "required": "0.0150",
    "currency": "USD",
    "topUpUrl": "https://mixmedia.tech/cabinet/billing"
  },
  "error": "payment_required"
}

429

{
  "code": 429,
  "msg": "Rate limit exceeded: 10 createTask/upload requests per 10 s per key. Retry after 8s",
  "data": null,
  "error": "rate_limit_error"
}

500

{
  "code": 500,
  "msg": "Internal server error",
  "data": null,
  "error": "server_error"
}

Codes on createTask / upload

codeerrorMeaningWhat to do
400invalid_request_errorInvalid parameter or bodySee msg
400unsupported_modelUnknown modelModel list
400nsfw_content_detectedRejected by content check (nsfw_check)Change the prompt or files
401authentication_errorMissing or invalid keyCheck the key
402payment_requiredNot enough balanceTop up
403permission_errorNo accessContact support
429rate_limit_errorToo many requestsWait for Retry-After
505model_disabledModel temporarily disabledPick another
500server_errorOur failureRetry later

Example msg values: Authentication failed. Please check your API key (401); Insufficient balance. Please top up and try again… (402).

Task errors (recordInfo)

If the task was created and then failed: state: "fail" (alias status: "failed"), failCode / failMsg, and error: { code, message, type }. Money is refunded (refunded: true).

failCodeerror.typeMeaning
400nsfw_content_detected / invalid_request_errorModeration / safety rules
422invalid_request_errorThe model rejected the parameters (length, mode, resolution, file)
501server_errorThe model could not generate (failMsg)
504timeout_errorTimed out — retry
500 / 503server_errorService temporarily unavailable

Rate limits

WhatLimit
createTask and upload20 per 10 s per key
recordInfo / list / balance100 per 10 s per key

Over the limit — HTTP 429 and Retry-After.

© 2026 MixMedia