Skip to main content
POST
This page covers the official models grok-imagine-video and grok-imagine-video-1.5. They are separate from grok-imagine-1.5-video-ext on the existing generation page; do not mix their model names or parameters.
Never expose an API key in a browser bundle, public environment variable, LocalStorage, URL, or frontend logs. Call APIMart through your backend or BFF.

Integration overview

All modes use the same asynchronous endpoint:
After submission, save data[0].task_id, then poll:
Do not send X-APIMart-Response-Version. It switches to an HTTP 202 response schema; this page uses the legacy HTTP 200 asynchronous task response.

Model capabilities

The public contract does not define a fixed reference-image count limit. Keep a non-empty array of valid URLs in their original order; do not reuse image-model limits.

Request headers

string
required
Bearer <APIMART_API_KEY>
string
required
Always use application/json.
string
application/json
string
Idempotency-Key is optional and strongly recommended for paid generation and editing. It accepts 1–191 visible ASCII characters; UUID is recommended. Reuse the original key and identical body for a network retry. Do not switch keys when the result is uncertain.Use a new key for each new logical operation. A retry of the same operation must reuse the original key and identical body.

Request parameters

Common fields

string
required
Official model name; video editing supports the base model only
  • grok-imagine-video
  • grok-imagine-video-1.5
string
required
Non-empty instruction, at most 8000 Unicode charactersArray.from(prompt).length
boolean
default:false
Whether to perform content moderation before submitting the video task.
  • true: Use omni-moderation-latest to review the prompt and input images
  • false or omitted: Do not send a moderation request, adding no moderation cost or latency (default)

Generation fields

integer
default:8
Generation only; integer from 1 to 15, default 8
string
default:"480p"
Base: 480p/720p; 1.5: 480p/720p/1080p; default 480p
  • grok-imagine-video: 480p, 720p
  • grok-imagine-video-1.5: 480p, 720p, 1080p
string
default:"auto"
Generation only; auto, 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, or 2:3
  • auto
  • 1:1, 16:9, 9:16
  • 4:3, 3:4, 3:2, 2:3
string[]
Optional reference-image array; every item must be a public HTTPS URL; omit instead of sending an empty array
  • Every item must be a publicly accessible HTTPS URL; relative URLs, Data URLs, and raw Base64 are not supported.
  • Do not send aliases such as image, images, or input_reference.
  • Array order is preserved; duplicate URLs occupy multiple input slots and may be billed more than once.

Video-edit fields

object
Source video object {url}; public HTTPS URL; base model only
A video-edit request requires model, prompt, and video, and may optionally include nsfw_check. Do not send duration, resolution, aspect_ratio, or image_urls; the platform detects the source duration.

TypeScript request types

Use a discriminated union so generation-only fields cannot be sent to video editing.

Request examples

Asynchronous tasks

Create success

A successful create request returns HTTP 200. Save data[0].task_id; submission does not mean the video is complete. A task ID means submitted, not completed.

Query a task

Poll GET /v1/tasks/{task_id} every 3–5 seconds. Resume polling with the saved task ID after a page refresh.

Completed response

result.videos[0].url is an array of strings, not a single string. Validate every value as an HTTPS URL before display. Runtime validation is recommended:
Use expires_at as the source of truth for URL expiry. Do not hard-code a lifetime; prompt users to download or persist the result.

Failed response

A task query can return HTTP 200 while data.status is failed. Determine success from data.status; failed tasks have cost=0.

Pricing catalog

Read GET /api/pricing/models/all and find the model by id in data.models.video. Prices are estimates; the authoritative final amount is data.cost from the task response.

Output-video pricing

  • Pricing keys use uppercase 480P/720P/1080P, while request values use lowercase; normalize case when looking up prices.
  • default is compatibility metadata, not a selectable resolution.
  • Use after_discount directly; do not apply the discount again.

Input-material pricing

Video input pricing is a scalar object. Do not require items, billing_mode, or max_billable_seconds. Model 1.5 has no video-input price because it cannot edit video.

Estimate formulas

User-specific pricing and server-side rounding can change the estimate. The final amount is always task data.cost.

Frontend rules

Model switching

  • Base model shows only 480p/720p; 1.5 also shows 1080p.
  • Switching from 1.5 1080p to base must fall back to 480p.
  • Video-edit mode fixes the model to grok-imagine-video.

Mode switching

nsfw_check is optional in every mode. Send true when moderation is enabled; omit it or send false when disabled. Disable the run button when any of these conditions applies:
  • Text mode omits image_urls and video.
  • Reference mode sends image_urls and omits video.
  • Video-edit mode clears all generation-only fields.
  • Disable submission for an empty or over-limit prompt, invalid duration, unsupported resolution, invalid material URL, active upload, or duplicate submission.
  • Limit prompts to 8000 Unicode characters and duration to integers from 1 to 15.
  • Use public HTTPS URLs only; omit empty image_urls.

Common errors

Frontend checklist

  • Keep the API key only in the backend or BFF.
  • Do not mix official model names with grok-imagine-1.5-video-ext.
  • Limit prompts to 8000 Unicode characters and duration to integers from 1 to 15.
  • Use public HTTPS URLs only; omit empty image_urls.
  • Send only model/prompt/video plus optional nsfw_check for video editing, and use the base model.
  • Read data[0].task_id on submit and determine the terminal state from data.status.
  • Read output from result.videos[].url[] and respect expires_at.
  • Use catalog prices for display and task data.cost for the final amount.