Playground
curl --request POST \
--url https://api.widerouter.com/v1/task/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": {
"input.prompt": "<string>",
"input.resolution": "<string>",
"input.quality": "<string>",
"input.aspect_ratio": "<string>",
"input.n": 123,
"input.images": [
"<string>"
]
},
"callback_url": "<string>"
}
'import requests
url = "https://api.widerouter.com/v1/task/submit"
payload = {
"model": "<string>",
"input": {
"input.prompt": "<string>",
"input.resolution": "<string>",
"input.quality": "<string>",
"input.aspect_ratio": "<string>",
"input.n": 123,
"input.images": ["<string>"]
},
"callback_url": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
input: {
'input.prompt': '<string>',
'input.resolution': '<string>',
'input.quality': '<string>',
'input.aspect_ratio': '<string>',
'input.n': 123,
'input.images': ['<string>']
},
callback_url: '<string>'
})
};
fetch('https://api.widerouter.com/v1/task/submit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.widerouter.com/v1/task/submit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'input' => [
'input.prompt' => '<string>',
'input.resolution' => '<string>',
'input.quality' => '<string>',
'input.aspect_ratio' => '<string>',
'input.n' => 123,
'input.images' => [
'<string>'
]
],
'callback_url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.widerouter.com/v1/task/submit"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.resolution\": \"<string>\",\n \"input.quality\": \"<string>\",\n \"input.aspect_ratio\": \"<string>\",\n \"input.n\": 123,\n \"input.images\": [\n \"<string>\"\n ]\n },\n \"callback_url\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.widerouter.com/v1/task/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.resolution\": \"<string>\",\n \"input.quality\": \"<string>\",\n \"input.aspect_ratio\": \"<string>\",\n \"input.n\": 123,\n \"input.images\": [\n \"<string>\"\n ]\n },\n \"callback_url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.widerouter.com/v1/task/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.resolution\": \"<string>\",\n \"input.quality\": \"<string>\",\n \"input.aspect_ratio\": \"<string>\",\n \"input.n\": 123,\n \"input.images\": [\n \"<string>\"\n ]\n },\n \"callback_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "task_2wZ1SuRH4VzXxONqGrH9oCLEZiBQTAVF",
"status": "queued",
"created_at": 1788189088
}
Grok Imagine 图片
Playground
直接在页面里提交一个真实的 Grok Imagine 图像任务,再用返回的任务 ID 轮询结果。
POST
/
v1
/
task
/
submit
Playground
curl --request POST \
--url https://api.widerouter.com/v1/task/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": {
"input.prompt": "<string>",
"input.resolution": "<string>",
"input.quality": "<string>",
"input.aspect_ratio": "<string>",
"input.n": 123,
"input.images": [
"<string>"
]
},
"callback_url": "<string>"
}
'import requests
url = "https://api.widerouter.com/v1/task/submit"
payload = {
"model": "<string>",
"input": {
"input.prompt": "<string>",
"input.resolution": "<string>",
"input.quality": "<string>",
"input.aspect_ratio": "<string>",
"input.n": 123,
"input.images": ["<string>"]
},
"callback_url": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
input: {
'input.prompt': '<string>',
'input.resolution': '<string>',
'input.quality': '<string>',
'input.aspect_ratio': '<string>',
'input.n': 123,
'input.images': ['<string>']
},
callback_url: '<string>'
})
};
fetch('https://api.widerouter.com/v1/task/submit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.widerouter.com/v1/task/submit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'input' => [
'input.prompt' => '<string>',
'input.resolution' => '<string>',
'input.quality' => '<string>',
'input.aspect_ratio' => '<string>',
'input.n' => 123,
'input.images' => [
'<string>'
]
],
'callback_url' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.widerouter.com/v1/task/submit"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.resolution\": \"<string>\",\n \"input.quality\": \"<string>\",\n \"input.aspect_ratio\": \"<string>\",\n \"input.n\": 123,\n \"input.images\": [\n \"<string>\"\n ]\n },\n \"callback_url\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.widerouter.com/v1/task/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.resolution\": \"<string>\",\n \"input.quality\": \"<string>\",\n \"input.aspect_ratio\": \"<string>\",\n \"input.n\": 123,\n \"input.images\": [\n \"<string>\"\n ]\n },\n \"callback_url\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.widerouter.com/v1/task/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.resolution\": \"<string>\",\n \"input.quality\": \"<string>\",\n \"input.aspect_ratio\": \"<string>\",\n \"input.n\": 123,\n \"input.images\": [\n \"<string>\"\n ]\n },\n \"callback_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "task_2wZ1SuRH4VzXxONqGrH9oCLEZiBQTAVF",
"status": "queued",
"created_at": 1788189088
}
填入你的 API Key 和提示词,然后发送。这里打的是线上接口,和你代码里调的是同一个。
完成的任务带一个
从这个页面发出的请求是真实的,会计入你的 Key。
一张图按模型和档位不同约 $0.02 到 $0.08。这里没有沙箱,也没有 mock。
参数
string
必填
用哪个模型。接受
grok-imagine-image、grok-imagine-image-2.0 或
grok-imagine-image-quality,精确匹配,没有别名。object
必填
生成参数。下面没列出的键一律以
invalid_params 拒绝。显示 input
显示 input
string
必填
要生成什么。不能为空,最长 32000 字节。
string
默认值:"1k"
1k 或 2k,小写——大写会被拒。string
默认值:"low"
low 或 medium。只有 grok-imagine-image-2.0 接受,
另外两个模型上它会被当成未知字段。string
取
auto 1:1 16:9 9:16 4:3 3:4 3:2 2:3 2:1 1:2
19.5:9 9:19.5 20:9 9:20 21:9 5:2 之一。
不传则用该模型自己的默认画幅。integer
默认值:"1"
出几张图,1 到 4。每一张在
outputs 里是独立一项,也各自计费。string[]
用来编辑或合成的参考图,最多 3 张。每一项是
https URL 或 base64 data URI,
每张另加约 $0.01。string
任务结束后把结果 POST 到这个地址,省掉轮询。必须是
https,
其他形式在提交时就会被拒。会返回什么
提交立刻返回,一秒都用不到。图片不在这个响应里——生成是在后台进行的。| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务 ID,后面每一步都要用它。 |
status | string | 新任务是 queued。 |
created_at | integer | Unix 秒,UTC。 |
{
"id": "task_2wZ1SuRH4VzXxONqGrH9oCLEZiBQTAVF",
"status": "queued",
"created_at": 1788189088
}
然后轮询取结果
这个 Playground 只覆盖创建调用。拿上面响应里的id 去读任务,
直到 status 变成 completed 或 failed——大约 7 到 10 秒。
curl https://api.widerouter.com/v1/task/$TASK_ID \
-H "Authorization: Bearer $WIDEROUTER_API_KEY"
outputs 数组:
{
"id": "task_2wZ1SuRH4VzXxONqGrH9oCLEZiBQTAVF",
"model": "grok-imagine-image",
"status": "completed",
"created_at": 1788189088,
"completed_at": 1788189094,
"expires_at": 1788275494,
"outputs": ["https://r2cdn.agisuitepro.com/o/2026/08/31/task_2wZ1SuRH4VzXxONqGrH9oCLEZiBQTAVF_0.jpg"],
"counts": { "requested": 1, "succeeded": 1, "failed": 0 },
"usage": { "cost_in_usd_ticks": 200000000 }
}
产物 URL 不鉴权,并且在任务完成 24 小时后失效。
usage.cost_in_usd_ticks 是原价,实际扣费是它乘以你所在分组的倍率——
见计价。下一步
概览
全部参数、分辨率与质量的组合,以及实测时延。
异步任务 API
轮询闭环、回调,以及完整错误表。