imagesarray
List of URLs of the images to edit. A maximum of 3 images are supported.
xai/grok-imagine-image/2.0/editGrok Imagine Image 2.0 Edit is xAI's intelligent image editing model. Transform, retouch, and reimagine existing images using text prompts - from background replacement to artistic style conversion.
Thử model
PNG, JPEG, WebP, or GIF · 20 MiB maximum each
Chọn một ví dụ để nạp đầu vào và kết quả của nó vào playground.
{
"prompt": "Make this scene more realistic but still keep the game vibes"
}Sở thích con người
Điểm Elo từ các lượt bình chọn ẩn, so sánh với các mô hình hình ảnh và video khác.
Xếp hạng lấy từ Artificial Analysis Arena
Arena chỉnh sửa hình ảnh: người dùng chọn bản tốt hơn trong hai lần chỉnh sửa cùng một hình và cùng một hướng dẫn, không thấy tên model.
Grok Imagine Image 2.0 edit: change or combine images at two quality levels.
| Field | Type | Default | Notes |
|---|---|---|---|
prompt | string, required | — | Up to 8,000 characters. |
images | image URL[] | — | Images to edit or combine, Image 1, Image 2, … |
resolution | 1k / 2k | 1k | Sets the per-image rate. |
output_format | jpeg / png | jpeg | Output file format. |
quality | low / medium | medium | Sets the per-image rate. |
aspect_ratio | 21:9 / 16:9 / 3:2 / 4:3 / 5:4 / 1:1 / 4:5 / 3:4 / 2:3 / 9:16 | — | Output shape. |
Per output image: $0.04 (low) or $0.06 (medium) at 1K; $0.06 or $0.08 at 2K; plus $0.01 per input image.
| Request | 1k | 2k |
|---|---|---|
| low, 1 input | $0.05 | $0.07 |
| medium, 1 input | $0.07 | $0.09 |
Failed runs are not charged.
Other Grok Imagine Image endpoints: xai/grok-imagine-image/quality, xai/grok-imagine-image/quality/edit, xai/grok-imagine-image/edit, xai/grok-imagine-image/2.0/text-to-image.
Bắt đầu xây dựng
Gửi model này qua SandBase Unified Run API.
# The quoted heredoc keeps Unicode and shell metacharacters unchanged.
result=$(curl --fail-with-body --silent \
-X POST "https://api.sandbase.ai/v1/run" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'SANDBASE_JSON'
{
"model": "xai/grok-imagine-image/2.0/edit",
"prompt": "Make this scene more realistic but still keep the game vibes",
"quality": "medium",
"resolution": "1k",
"output_format": "jpeg"
}
SANDBASE_JSON
)
run_id=$(printf '%s' "$result" | jq -r .id)
for attempt in $(seq 1 120); do
status=$(printf '%s' "$result" | jq -r .status)
case "$status" in completed|failed|timeout) break ;; esac
sleep 2
result=$(curl --fail-with-body --silent \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
"https://api.sandbase.ai/v1/run/$run_id")
done
status=$(printf '%s' "$result" | jq -r .status)
[ "$status" = completed ] || { echo "Generation ended: $status" >&2; exit 1; }
printf '%s\n' "$result"Tạo một SandBase API key và đặt nó trong môi trường máy chủ của bạn. Tất cả request sử dụng xác thực Bearer.
export SANDBASE_API_KEY="YOUR_API_KEY"Giữ key trên máy chủ. Không hiển thị trong mã trình duyệt hoặc commit vào repository.
POST tới /v1/run với model ID này và các đầu vào của nó. Ví dụ request ở trên bao gồm cả bước gửi và polling.
Dùng run ID được trả về để poll cho đến khi trạng thái là completed, failed hoặc timeout. Chỉ đọc đầu ra sau khi completed.
curl "https://api.sandbase.ai/v1/run/$RUN_ID" \
-H "Authorization: Bearer $SANDBASE_API_KEY"Cung cấp một URL tệp có thể truy cập công khai trong trường image, video hoặc audio của model. Các định dạng và giới hạn được hỗ trợ hiển thị bên cạnh từng input trong Playground.
Dùng điều khiển upload hoặc replace trên các trường image được hỗ trợ trong Playground. Trường URL video chấp nhận một video driving được host; điều này không đồng nghĩa hỗ trợ tải lên video.
imagesarrayList of URLs of the images to edit. A maximum of 3 images are supported.
promptstringbắt buộcText description of the desired image.
qualitystringQuality level of the edited image.
Mặc định: "medium"
Giá trị có thể dùng: "low", "medium"
resolutionstringResolution of the generated image. `1k` for standard resolution, `2k` for high resolution.
Mặc định: "1k"
Giá trị có thể dùng: "1k", "2k"
aspect_ratiostringThe aspect ratio of the generated image.
Giá trị có thể dùng: "21:9", "16:9", "3:2", "4:3", "5:4", "1:1", "4:5", "3:4", "2:3", "9:16"
output_formatstringThe format of the generated image.
Mặc định: "jpeg"
Giá trị có thể dùng: "jpeg", "png"
{
"model": "xai/grok-imagine-image/2.0/edit",
"prompt": "Make this scene more realistic but still keep the game vibes",
"quality": "medium",
"resolution": "1k",
"output_format": "jpeg"
}Một run đã hoàn tất sẽ hiển thị kết quả trong output. Phần sau là ví dụ đã lưu của model, không phải một lần tạo mới.
[
{
"source": "xAI schema mirror",
"source_url": "https://docs.x.ai/",
"url": "https://static.sandbase.ai/examples/c73441b8-80d0-4d22-9ea7-33962ff210b9/output/4c051d8c-762c-4b5a-b14e-bf612672acc0.jpg"
}
]