curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-imagine-1.0",
"prompt": "一只橘猫坐在阳光窗台上,油画风格",
"size": "1:1",
"n": 1
}'
import requests
resp = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json",
},
json={
"model": "grok-imagine-1.0",
"prompt": "一只橘猫坐在阳光窗台上,油画风格",
"size": "1:1",
"n": 1,
},
)
print(resp.status_code)
print(resp.json())
const resp = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'grok-imagine-1.0',
prompt: '一只橘猫坐在阳光窗台上,油画风格',
size: '1:1',
n: 1,
}),
});
console.log(resp.status);
console.log(await resp.json());
{
"id": "task_01JNXXXXXXXXXXXXXXXXXX",
"object": "generation.task",
"model": "grok-imagine-1.0",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
Grok Imagine 1.0
Grok Imagine 1.0 图像生成
使用 grok-imagine-1.0 进行异步图像生成
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-imagine-1.0",
"prompt": "一只橘猫坐在阳光窗台上,油画风格",
"size": "1:1",
"n": 1
}'
import requests
resp = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json",
},
json={
"model": "grok-imagine-1.0",
"prompt": "一只橘猫坐在阳光窗台上,油画风格",
"size": "1:1",
"n": 1,
},
)
print(resp.status_code)
print(resp.json())
const resp = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'grok-imagine-1.0',
prompt: '一只橘猫坐在阳光窗台上,油画风格',
size: '1:1',
n: 1,
}),
});
console.log(resp.status);
console.log(await resp.json());
{
"id": "task_01JNXXXXXXXXXXXXXXXXXX",
"object": "generation.task",
"model": "grok-imagine-1.0",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
- 统一图像生成接口
- 异步任务模式,返回任务 ID
- 通过
model指定为grok-imagine-1.0
Authorizations
string
必填
Body
string
必填
模型名称,固定使用:
grok-imagine-1.0
string
必填
图像生成提示词,支持多语言
string
默认值:"1:1"
图像生成尺寸支持的格式:
1:1- 正方形(默认)16:9- 横版宽屏9:16- 竖版长屏3:2- 横版2:3- 竖版
integer
默认值:1
生成图像数量取值范围:1-10(最少 1 张,最多 10 张)⚠️ 注意:必须输入纯数字(如
1),不要加引号,否则会报错Response
string
任务唯一 ID
string
固定为
generation.taskstring
任务状态:
queued / in_progress / completed / failedcurl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-imagine-1.0",
"prompt": "一只橘猫坐在阳光窗台上,油画风格",
"size": "1:1",
"n": 1
}'
import requests
resp = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json",
},
json={
"model": "grok-imagine-1.0",
"prompt": "一只橘猫坐在阳光窗台上,油画风格",
"size": "1:1",
"n": 1,
},
)
print(resp.status_code)
print(resp.json())
const resp = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'grok-imagine-1.0',
prompt: '一只橘猫坐在阳光窗台上,油画风格',
size: '1:1',
n: 1,
}),
});
console.log(resp.status);
console.log(await resp.json());
{
"id": "task_01JNXXXXXXXXXXXXXXXXXX",
"object": "generation.task",
"model": "grok-imagine-1.0",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
⌘I