模型市场支持← 返回应用

Grok Imagine

Grok Imagine 模型通过一个统一的异步任务 API 调用。用 POST /api/generate 发起任务,再轮询 GET /api/generate/{taskId} 直到完成。本系列提供 7 个端点。

概览

每个端点共享相同的外层结构 —— 只有 modelinput 字段不同。可在模型市场的 playground 中运行任意一个。

认证

/api-keys 创建 API 密钥,然后作为 Bearer token 发送。已登录时从浏览器发起的请求也可通过会话 cookie 生效。

Authorization: Bearer <YOUR_API_KEY>

创建任务

POST
POST https://api.lithovas.com/api/generate

请求体:{ "model": "<slug>", "input": { … } }

响应:{ "taskId": "<id>", "state": "waiting" }

查询结果

GET
GET https://api.lithovas.com/api/generate/<taskId>

响应:{ "taskId", "state": "waiting" | "success" | "fail", "resultUrls": [ … ], "creditsConsumed", "failMsg", "balance" }

异步
创建任务返回 200 只表示任务已被接受 —— 并非已完成。请轮询此端点,直到 state 变为 successfail。失败任务不计费。

端点

模型任务model slug
Grok ImagineText to Imagegrok-imagine/text-to-image
Grok ImagineImage to Imagegrok-imagine/image-to-image
Grok ImagineText to Videogrok-imagine/text-to-video
Grok ImagineImage to Videogrok-imagine/image-to-video
Grok ImagineImage to Videogrok-imagine/upscale
Grok ImagineImage to Videogrok-imagine/extend
Grok Imagine 1.5 PreviewImage to Videogrok-imagine/1-5-preview

Grok Imagine · Text to Image

POSTText to Imagegrok-imagine/text-to-image
input 字段
promptstring必填

Text prompt describing the desired image (max 5000 chars)

aspect_ratioenum<string>可选

Width-to-height ratio of generated image

nsfw_checkerboolean可选

Content filtering; disabled when false

enable_proboolean可选

Quality mode (true) vs speed mode (false)

示例
cURL
curl -X POST https://api.lithovas.com/api/generate \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine/text-to-image",
  "input": {
    "prompt": "A cinematic red panda surfing through neon rain at dusk.",
    "aspect_ratio": "1:1",
    "nsfw_checker": false,
    "enable_pro": false
  }
}'

Grok Imagine · Image to Image

POSTImage to Imagegrok-imagine/image-to-image
input 字段
promptstring可选

Text description specifying desired content or style

image_urlsarray<string>必填

Up to 1 reference image URL (JPEG/PNG/WebP, max 10MB)

nsfw_checkerboolean可选

Toggle content filtering; false disables filtering

示例
cURL
curl -X POST https://api.lithovas.com/api/generate \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine/image-to-image",
  "input": {
    "prompt": "A cinematic red panda surfing through neon rain at dusk.",
    "image_urls": [
      "https://example.com/input.jpg"
    ],
    "nsfw_checker": false
  }
}'

Grok Imagine · Text to Video

POSTText to Videogrok-imagine/text-to-video
input 字段
promptstring必填

Text prompt describing desired video motion (max 5000 chars)

aspect_ratioenum<string>可选

Width-to-height ratio of the generated video

modeenum<string>可选

Generation mode affecting style and intensity of motion

durationnumber可选

Video length in seconds (range 6-30, step 1)

resolutionenum<string>可选

The resolution of the generated video

nsfw_checkerboolean可选

Disables content filtering when set to false

示例
cURL
curl -X POST https://api.lithovas.com/api/generate \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine/text-to-video",
  "input": {
    "prompt": "A cinematic red panda surfing through neon rain at dusk.",
    "aspect_ratio": "2:3",
    "mode": "normal",
    "duration": 5,
    "resolution": "480p",
    "nsfw_checker": false
  }
}'

Grok Imagine · Image to Video

POSTImage to Videogrok-imagine/image-to-video
input 字段
image_urlsarray<string>可选

External image URLs for video (max 7, JPEG/PNG/WEBP, 10MB each)

task_idstring可选

Task ID from previous Grok text-to-image generation (max 100 chars)

indexinteger可选

Image index when using task_id (0-5, 0-based)

promptstring可选

Text describing desired video motion (max 5000 chars)

modeenum<string>可选

Generation mode: fun, normal, spicy

durationstring可选

Video duration in seconds (6-30 range, 1 second steps)

resolutionenum<string>可选

Output video resolution

aspect_ratioenum<string>可选

Video aspect ratio for multi-image mode

nsfw_checkerboolean可选

Enable content filtering (disabled by default)

示例
cURL
curl -X POST https://api.lithovas.com/api/generate \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine/image-to-video",
  "input": {
    "image_urls": [
      "https://example.com/input.jpg"
    ],
    "task_id": "example",
    "index": 0,
    "prompt": "Animate the image with natural motion, subtle camera movement, and cinematic lighting.",
    "mode": "normal",
    "duration": 5,
    "resolution": "480p",
    "aspect_ratio": "16:9",
    "nsfw_checker": false
  }
}'

Grok Imagine · Image to Video

POSTImage to Videogrok-imagine/upscale
input 字段
task_idstring必填

Task ID from a previously successful video generation task

示例
cURL
curl -X POST https://api.lithovas.com/api/generate \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine/upscale",
  "input": {
    "task_id": "example"
  }
}'

Grok Imagine · Image to Video

POSTImage to Videogrok-imagine/extend
input 字段
task_idstring必填

Task ID from previous video generation (Kie AI models only)

promptstring必填

Text instructions describing desired video movement and expansion

extend_atnumber可选

Starting position for video extension

extend_timesnumber必填

Duration of video extension in seconds (6 or 10 seconds)

示例
cURL
curl -X POST https://api.lithovas.com/api/generate \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine/extend",
  "input": {
    "task_id": "example",
    "prompt": "Animate the image with natural motion, subtle camera movement, and cinematic lighting.",
    "extend_at": 2,
    "extend_times": 1
  }
}'

Grok Imagine 1.5 Preview · Image to Video

POSTImage to Videogrok-imagine/1-5-preview
input 字段
promptstring必填

Prompt for video generation (max 4096 chars)

image_urlsarray<string>可选

Image files for input (JPEG/PNG/WebP/JPG, max 20MB, up to 1 file)

aspect_ratioenum<string>可选

Aspect ratio for video generation

resolutionenum<string>可选

Resolution for video generation

durationinteger可选

Video duration in seconds (range 1-15)

nsfw_checkerboolean可选

If set to false, content filtering is disabled

示例
cURL
curl -X POST https://api.lithovas.com/api/generate \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine/1-5-preview",
  "input": {
    "prompt": "Animate the image with natural motion, subtle camera movement, and cinematic lighting.",
    "image_urls": [
      "https://example.com/input.jpg"
    ],
    "aspect_ratio": "auto",
    "resolution": "480p",
    "duration": 8,
    "nsfw_checker": false
  }
}'