← 返回
未分类 Key 中文

Grok Imagine Image

Generate images with xAI Grok Imagine models — batch generation, aspect ratios, base64 output, concurrent requests. Use when user wants AI image generation v...
使用xAI Grok Imagine模型生成图像 — 批量生成、多种宽高比、Base64输出、并发请求。适用于用户需要AI图像生成的场景。
maliot100x maliot100x 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 62
下载
💾 0
安装
1
版本
#latest

概述

xAI Image Generation

Generate images from text with Grok Imagine models. Supports batch, aspect ratio, resolution, base64, and concurrent requests.

When to Use

  • User asks to generate an image
  • User wants AI art or visuals
  • User needs batch image generation
  • User wants images for social media, marketing, or content

Quick Start

curl -X POST https://api.x.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -d '{
    "model": "grok-imagine-image-quality",
    "prompt": "A futuristic city skyline at night"
  }'

Models

ModelStatusUse Case
-------------------------
grok-imagine-image-quality✅ CurrentAll new requests
grok-imagine-image-pro⚠️ Deprecated May 2026Legacy, migrate to quality

Parameters

  • prompt (required) — Text description
  • model (required) — grok-imagine-image-quality
  • n (optional) — Number of images (1-4)
  • response_format (optional) — url (default) or b64_json

Examples

Single Image

curl -X POST https://api.x.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -d '{
    "model": "grok-imagine-image-quality",
    "prompt": "A collage of London landmarks in stenciled street-art style"
  }'

Multiple Variations

curl -X POST https://api.x.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -d '{
    "model": "grok-imagine-image-quality",
    "prompt": "A futuristic city skyline at night",
    "n": 4
  }'

Base64 Output

curl -X POST https://api.x.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -d '{
    "model": "grok-imagine-image-quality",
    "prompt": "A serene Japanese garden",
    "response_format": "b64_json"
  }'

Response Format

{
  "data": [
    {
      "url": "https://...",
      "b64_json": "..."
    }
  ]
}

Python SDK

import xai_sdk

client = xai_sdk.Client()
response = client.image.sample(
    prompt="A futuristic city skyline",
    model="grok-imagine-image-quality",
)
print(response.url)

OpenAI SDK Compatible

from openai import OpenAI

client = OpenAI(
    base_url="https://api.x.ai/v1",
    api_key="YOUR_XAI_API_KEY",
)

response = client.images.generate(
    model="grok-imagine-image-quality",
    prompt="A futuristic city skyline",
)
print(response.data[0].url)

Tips

  • URLs are temporary — download promptly
  • Use b64_json for embedding
  • Use n parameter for batch variations
  • Use async for concurrent different prompts
  • Check respect_moderation for content filtering

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-06-09 19:33 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Grok Code Review

maliot100x
专家级安全优先的代码审查,适用于对代码、diff、PR 或实现进行错误、安全漏洞、质量和性能审计。
★ 1 📥 88

Yuanbao

maliot100x
元宝群组:@提及用户,查询信息/成员
★ 0 📥 99

Find Popular Skills

maliot100x
在 skills.sh(1.9M+ 生态系统)和 ClawHub 发现并安装最佳代理技能,按类别查找热门技能、查看排行榜、验证质量等。
★ 1 📥 114