- Third-party
xAI 的 Grok Imagine 图像模型。可根据文本和参考图像输入生成和编辑图像,支持配置宽高比和分辨率。
| 模型信息 | |
|---|---|
| 条款和许可证 | 链接 ↗ |
| 更多信息 | 链接 ↗ |
| 定价 | 在 Cloudflare 仪表板中查看定价 ↗ |
用法
const response = await env.AI.run(
'xai/grok-imagine-image',
{ prompt: 'A golden retriever puppy playing in autumn leaves' },
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "xai/grok-imagine-image",
"input": {
"prompt": "A golden retriever puppy playing in autumn leaves"
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/simple-generation.jpeg"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}示例
自定义宽高比 — 2K 分辨率的竖向渲染
const response = await env.AI.run(
'xai/grok-imagine-image',
{
prompt:
'A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures',
aspect_ratio: '3:4',
resolution: '2k',
},
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "xai/grok-imagine-image",
"input": {
"prompt": "A detailed botanical illustration of exotic tropical flowers with fine line work and watercolor textures",
"aspect_ratio": "3:4",
"resolution": "2k"
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/custom-aspect-ratio.png"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}电影感风景 — 2K 分辨率的宽屏风景
const response = await env.AI.run(
'xai/grok-imagine-image',
{
prompt:
'A neon-lit cyberpunk figure standing in the rain beneath a holographic billboard, cinematic lighting',
aspect_ratio: '16:9',
resolution: '2k',
},
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "xai/grok-imagine-image",
"input": {
"prompt": "A neon-lit cyberpunk figure standing in the rain beneath a holographic billboard, cinematic lighting",
"aspect_ratio": "16:9",
"resolution": "2k"
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/xai/grok-imagine-image/cinematic-landscape.png"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}参数
prompt
stringrequiredn
integerminimum: 1maximum: 10aspect_ratio
stringenum: 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2, 9:19.5, 19.5:9, 9:20, 20:9, 1:2, 2:1, autoquality
stringenum: low, medium, highresolution
stringenum: 1k, 2kresponse_format
stringenum: url, b64_jsonuser
string▶image{}
object▶images[]
arraymaxItems: 10▶mask{}
objectimage
string