curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "未来城市的空中花园,建筑摄影,清晨阳光",
"n": 1,
"aspect_ratio": "16:9",
"resolution": "1k",
"response_format": "url"
}'
curl https://sub.vcnovb.cn/v1/images/edits \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "将白天改为蓝调夜景,保留建筑轮廓",
"image": {"url": "https://example.com/city.png"},
"n": 1,
"response_format": "url"
}'
import os
import requests
response = requests.post(
"https://sub.vcnovb.cn/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['VC_API_KEY']}"},
json={
"model": "grok-imagine-image-2.0",
"prompt": "未来城市的空中花园,建筑摄影,清晨阳光",
"n": 1, "aspect_ratio": "16:9", "resolution": "1k",
"response_format": "url",
},
timeout=180,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://sub.vcnovb.cn/v1/images/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VC_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "grok-imagine-image-2.0",
prompt: "未来城市的空中花园,建筑摄影,清晨阳光",
n: 1, aspect_ratio: "16:9", resolution: "1k", response_format: "url",
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{"created":1794614400,"data":[{"url":"https://example.com/grok-image.png"}]}
{"created":1794614400,"data":[{"b64_json":"BASE64_IMAGE_DATA"}]}
Image 图片
Grok Image 图片生成
Grok Image 的模型、比例、1K / 2K 分辨率、返回格式和参考图编辑。
POST
https://sub.vcnovb.cn
/
v1
/
images
/
generations
curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "未来城市的空中花园,建筑摄影,清晨阳光",
"n": 1,
"aspect_ratio": "16:9",
"resolution": "1k",
"response_format": "url"
}'
curl https://sub.vcnovb.cn/v1/images/edits \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "将白天改为蓝调夜景,保留建筑轮廓",
"image": {"url": "https://example.com/city.png"},
"n": 1,
"response_format": "url"
}'
import os
import requests
response = requests.post(
"https://sub.vcnovb.cn/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['VC_API_KEY']}"},
json={
"model": "grok-imagine-image-2.0",
"prompt": "未来城市的空中花园,建筑摄影,清晨阳光",
"n": 1, "aspect_ratio": "16:9", "resolution": "1k",
"response_format": "url",
},
timeout=180,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://sub.vcnovb.cn/v1/images/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VC_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "grok-imagine-image-2.0",
prompt: "未来城市的空中花园,建筑摄影,清晨阳光",
n: 1, aspect_ratio: "16:9", resolution: "1k", response_format: "url",
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{"created":1794614400,"data":[{"url":"https://example.com/grok-image.png"}]}
{"created":1794614400,"data":[{"b64_json":"BASE64_IMAGE_DATA"}]}
使用
结果链接请及时下载保存。编辑请求发送至
grok-imagine-image 或 grok-imagine-image-2.0 生成和编辑图片。API Key 需绑定具有图片权限的 Grok 分组。
curl https://sub.vcnovb.cn/v1/images/generations \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "未来城市的空中花园,建筑摄影,清晨阳光",
"n": 1,
"aspect_ratio": "16:9",
"resolution": "1k",
"response_format": "url"
}'
curl https://sub.vcnovb.cn/v1/images/edits \
-H "Authorization: Bearer $VC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "将白天改为蓝调夜景,保留建筑轮廓",
"image": {"url": "https://example.com/city.png"},
"n": 1,
"response_format": "url"
}'
import os
import requests
response = requests.post(
"https://sub.vcnovb.cn/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['VC_API_KEY']}"},
json={
"model": "grok-imagine-image-2.0",
"prompt": "未来城市的空中花园,建筑摄影,清晨阳光",
"n": 1, "aspect_ratio": "16:9", "resolution": "1k",
"response_format": "url",
},
timeout=180,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://sub.vcnovb.cn/v1/images/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VC_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "grok-imagine-image-2.0",
prompt: "未来城市的空中花园,建筑摄影,清晨阳光",
n: 1, aspect_ratio: "16:9", resolution: "1k", response_format: "url",
}),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{"created":1794614400,"data":[{"url":"https://example.com/grok-image.png"}]}
{"created":1794614400,"data":[{"b64_json":"BASE64_IMAGE_DATA"}]}
请求参数
模型 ID,示例使用
grok-imagine-image-2.0。可用型号见模型列表。比例与分辨率
使用aspect_ratio 设置画面比例,使用 resolution 选择 1K 或 2K。例如,"aspect_ratio": "16:9" 与 "resolution": "1k" 组合表示横版 1K 图片。
返回结果
| 字段 | 说明 |
|---|---|
data[].url | 图片下载地址 |
data[].b64_json | Base64 图片数据,解码后保存为文件 |
/v1/images/edits,并携带参考图和编辑提示词。