ninteger
Images to generate (1-10). Each image is billed.
デフォルト: 1
最小: 1
最大: 10
x-ai/grok-imagine-imageGrok Imagine Image by xAI generates images from a prompt or edits up to 5 input images, at $0.02 per image. Call it from this page, through /v1/run, or with the xAI Images API at SandBase.
モデルを試す
PNG, JPEG, WebP, or GIF · 20 MiB maximum each · up to 5
出力はここに表示されます
入力を完了してから[実行]をクリックしてください。
Grok Imagine Image is xAI's previous image model, at $0.02 per image. It generates images from a prompt, or edits and combines up to 5 input images. For better quality and 1.5K output, use Grok Imagine Image 2.0.
Use the form on this page, call x-ai/ through /v1/run, or call the xAI API below with model: grok-imagine-image. Both bill the same as xAI.
| Field | Type | Default | Notes |
|---|---|---|---|
prompt | string, required | — | What to draw, or what to change. |
images | image list, up to 5 | — | Images to edit or combine. Leave empty to generate. |
n | integer 1–10 | 1 | Images to generate. |
aspect_ratio | auto1:116:99:164:33:43:22:32:11:219.5:99:19.520:99:2021:95:2 | auto | Output shape. |
resolution | 1k / 2k | 1k | Output size; the price is the same. |
SandBase implements xAI's Images and Videos API under https://api.sandbase.ai/grok/v1. Requests and responses match xAI's API reference field by field, so the xAI SDK or any OpenAI-style HTTP client works after you change the base URL and use your SandBase API key.
| xAI | SandBase | |
|---|---|---|
| Base URL | https://api.x.ai/v1 | https://api.sandbase.ai/grok/v1 |
| Generate | POST /images/generations | POST /images/generations |
| Edit | POST /images/edits | POST /images/edits |
| Deferred result | GET /images/{request_id} | GET /images/{request_id} |
model | grok-imagine-image | grok-imagine-image |
curl https://api.sandbase.ai/grok/v1/images/edits \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image",
"prompt": "Turn this photo into a watercolor painting",
"image": {"url": "https://example.com/photo.jpg"},
"response_format": "url"
}'
quality and resolution: 1.5k are only available on Grok Imagine Image 2.0 and return 400 here, as they do at xAI.
$0.02 per image. Editing adds $0.002 per input image. Failed runs are not billed.
| Request | Price |
|---|---|
| Generate 1 image | $0.02 |
| Generate 4 images | $0.08 |
| Edit 1 input image | $0.022 |
開発を始める
このモデルを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": "x-ai/grok-imagine-image",
"n": 1,
"prompt": "A red fox standing in fresh snow at sunrise, soft golden light, shallow depth of field",
"resolution": "1k",
"aspect_ratio": "auto"
}
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"SandBaseのAPIキーを作成し、サーバー環境に設定してください。すべてのリクエストはBearer認証を使用します。
export SANDBASE_API_KEY="YOUR_API_KEY"キーはサーバー側で管理してください。ブラウザコードに公開したり、リポジトリにコミットしたりしないでください。
このモデルIDと入力を使って /v1/run にPOSTしてください。上のリクエスト例には送信とポーリングが含まれています。
返されたrun IDを使って、ステータスがcompleted、failed、timeoutになるまでポーリングしてください。出力はcompleted後にのみ読み取ってください。
curl "https://api.sandbase.ai/v1/run/$RUN_ID" \
-H "Authorization: Bearer $SANDBASE_API_KEY"モデルのimage、video、またはaudioフィールドに、公開アクセス可能なファイルURLを指定してください。対応形式と制限は各Playground入力の横に表示されます。
Playgroundの対応する画像フィールドでアップロードまたは置換を使用してください。video URLフィールドはホストされたドライビング動画を受け付けますが、動画アップロード対応を意味するものではありません。
nintegerImages to generate (1-10). Each image is billed.
デフォルト: 1
最小: 1
最大: 10
imagesarrayUp to 5 images to edit or combine (upload or public HTTPS URL). Leave empty to generate from the prompt.
promptstring必須Describe the image, or the change to make to the input images.
resolutionstringOutput size: 1k or 2k.
デフォルト: "1k"
指定可能な値: "1k", "2k"
aspect_ratiostringOutput aspect ratio. auto picks one from the prompt or the first input image.
デフォルト: "auto"
指定可能な値: "auto", "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "2:1", "1:2", "19.5:9", "9:19.5", "20:9", "9:20", "21:9", "5:2"
{
"model": "x-ai/grok-imagine-image",
"n": 1,
"prompt": "A red fox standing in fresh snow at sunrise, soft golden light, shallow depth of field",
"resolution": "1k",
"aspect_ratio": "auto"
}完了したrunの結果は出力に表示されます。以下はモデルに保存されたサンプルであり、新規生成ではありません。
まだ例の出力は公開されていません。完了したrunのレスポンスを確認するには、Playground → Result → JSON を使用してください。