Playground
curl --request POST \
--url https://api.widerouter.com/v1/tasks/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": {
"input.prompt": "<string>",
"input.n": 123,
"input.aspect_ratio": "<string>",
"input.image_size": "<string>",
"input.images": [
"<string>"
]
},
"callback_url": "<string>"
}
'import requests
url = "https://api.widerouter.com/v1/tasks/submit"
payload = {
"model": "<string>",
"input": {
"input.prompt": "<string>",
"input.n": 123,
"input.aspect_ratio": "<string>",
"input.image_size": "<string>",
"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.n': 123,
'input.aspect_ratio': '<string>',
'input.image_size': '<string>',
'input.images': ['<string>']
},
callback_url: '<string>'
})
};
fetch('https://api.widerouter.com/v1/tasks/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/tasks/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.n' => 123,
'input.aspect_ratio' => '<string>',
'input.image_size' => '<string>',
'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/tasks/submit"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.n\": 123,\n \"input.aspect_ratio\": \"<string>\",\n \"input.image_size\": \"<string>\",\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/tasks/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.n\": 123,\n \"input.aspect_ratio\": \"<string>\",\n \"input.image_size\": \"<string>\",\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/tasks/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.n\": 123,\n \"input.aspect_ratio\": \"<string>\",\n \"input.image_size\": \"<string>\",\n \"input.images\": [\n \"<string>\"\n ]\n },\n \"callback_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "task_dksUgWLYX4jIVueCACD8KwJzjR5JhRsI",
"status": "queued",
"created_at": 1788104112
}
Nano Banana 系列
Playground
直接在頁面裡提交一個真實的生成任務,再用返回的任務 ID 輪詢結果。
POST
/
v1
/
tasks
/
submit
Playground
curl --request POST \
--url https://api.widerouter.com/v1/tasks/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": {
"input.prompt": "<string>",
"input.n": 123,
"input.aspect_ratio": "<string>",
"input.image_size": "<string>",
"input.images": [
"<string>"
]
},
"callback_url": "<string>"
}
'import requests
url = "https://api.widerouter.com/v1/tasks/submit"
payload = {
"model": "<string>",
"input": {
"input.prompt": "<string>",
"input.n": 123,
"input.aspect_ratio": "<string>",
"input.image_size": "<string>",
"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.n': 123,
'input.aspect_ratio': '<string>',
'input.image_size': '<string>',
'input.images': ['<string>']
},
callback_url: '<string>'
})
};
fetch('https://api.widerouter.com/v1/tasks/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/tasks/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.n' => 123,
'input.aspect_ratio' => '<string>',
'input.image_size' => '<string>',
'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/tasks/submit"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.n\": 123,\n \"input.aspect_ratio\": \"<string>\",\n \"input.image_size\": \"<string>\",\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/tasks/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": {\n \"input.prompt\": \"<string>\",\n \"input.n\": 123,\n \"input.aspect_ratio\": \"<string>\",\n \"input.image_size\": \"<string>\",\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/tasks/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.n\": 123,\n \"input.aspect_ratio\": \"<string>\",\n \"input.image_size\": \"<string>\",\n \"input.images\": [\n \"<string>\"\n ]\n },\n \"callback_url\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "task_dksUgWLYX4jIVueCACD8KwJzjR5JhRsI",
"status": "queued",
"created_at": 1788104112
}
填入你的 API Key 和提示詞,然後傳送。這裡打的是線上介面,和你程式碼裡調的是同一個。
完成的任務帶一個
從這個頁面發出的請求是真實的,會計入你的 Key。
一張 1K 圖按模型不同約 $0.02–0.09。這裡沒有沙箱,也沒有 mock。
參數
string
必填
用哪個模型。接受
gemini-3-pro-image 或 gemini-3.1-flash-image,
精確匹配——沒有別名,也不接受 -preview 字尾。object
必填
生成參數。下面沒列出的鍵一律以
invalid_params 拒絕。string
任務結束後把結果 POST 到這個地址,省掉輪詢。必須是
https,
其他形式在提交時就會被拒。會返回什麼
提交立刻返回,一秒都用不到。圖片不在這個響應裡——生成是在後臺進行的。| 欄位 | 型別 | 說明 |
|---|---|---|
id | string | 任務 ID,後面每一步都要用它。 |
status | string | 新任務是 queued。 |
created_at | integer | Unix 秒,UTC。 |
{
"id": "task_dksUgWLYX4jIVueCACD8KwJzjR5JhRsI",
"status": "queued",
"created_at": 1788104112
}
然後輪詢取圖
這個 Playground 只覆蓋建立呼叫。拿上面響應裡的id 去讀任務,
直到 status 變成 completed 或 failed——一張 1K 圖大約 15–40 秒。
curl https://api.widerouter.com/v1/task/$TASK_ID \
-H "Authorization: Bearer $WIDEROUTER_API_KEY"
outputs 陣列,裡面是圖片 URL:
{
"id": "task_dksUgWLYX4jIVueCACD8KwJzjR5JhRsI",
"status": "completed",
"outputs": ["https://…/task_dksUgWLYX4jIVueCACD8KwJzjR5JhRsI_0.jpg"],
"counts": { "requested": 1, "succeeded": 1, "failed": 0 }
}
產物 URL 不鑑權,並且在任務建立 24 小時後失效。下載時要帶
User-Agent——
分發 CDN 對不帶這個頭的請求直接返回 403。下一步
概覽
這個系列的全部參數、解析度檔位與實測時延。
非同步任務 API
輪詢閉環、回撥,以及完整錯誤表。