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