图片生成(异步)
curl --request POST \
--url https://api.senseaudio.cn/v1/image/async \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"reference": "<string>",
"seed": 123,
"size": "<string>"
}
'import requests
url = "https://api.senseaudio.cn/v1/image/async"
payload = {
"prompt": "<string>",
"reference": "<string>",
"seed": 123,
"size": "<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({prompt: '<string>', reference: '<string>', seed: 123, size: '<string>'})
};
fetch('https://api.senseaudio.cn/v1/image/async', 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.senseaudio.cn/v1/image/async",
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([
'prompt' => '<string>',
'reference' => '<string>',
'seed' => 123,
'size' => '<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.senseaudio.cn/v1/image/async"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"reference\": \"<string>\",\n \"seed\": 123,\n \"size\": \"<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.senseaudio.cn/v1/image/async")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"reference\": \"<string>\",\n \"seed\": 123,\n \"size\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.senseaudio.cn/v1/image/async")
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 \"prompt\": \"<string>\",\n \"reference\": \"<string>\",\n \"seed\": 123,\n \"size\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"task_id": "<string>"
}图片生成
异步图片生成
POST
/
v1
/
image
/
async
图片生成(异步)
curl --request POST \
--url https://api.senseaudio.cn/v1/image/async \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"reference": "<string>",
"seed": 123,
"size": "<string>"
}
'import requests
url = "https://api.senseaudio.cn/v1/image/async"
payload = {
"prompt": "<string>",
"reference": "<string>",
"seed": 123,
"size": "<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({prompt: '<string>', reference: '<string>', seed: 123, size: '<string>'})
};
fetch('https://api.senseaudio.cn/v1/image/async', 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.senseaudio.cn/v1/image/async",
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([
'prompt' => '<string>',
'reference' => '<string>',
'seed' => 123,
'size' => '<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.senseaudio.cn/v1/image/async"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"reference\": \"<string>\",\n \"seed\": 123,\n \"size\": \"<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.senseaudio.cn/v1/image/async")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"reference\": \"<string>\",\n \"seed\": 123,\n \"size\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.senseaudio.cn/v1/image/async")
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 \"prompt\": \"<string>\",\n \"reference\": \"<string>\",\n \"seed\": 123,\n \"size\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"task_id": "<string>"
}说明
异步方式生成图片,获得异步任务ID。获得异步任务ID后可使用查询图片任务 API轮询图片生成状态。 对于需要保持 HTTP 请求连接并最终返回图片数据的 API,见同步图片生成 API。图片大小要求
不同模型具有不同的图片大小要求:| 模型 | 可选尺寸 |
|---|---|
| senseaudio-image-2.0-260319 | 1024x1024 1536x864 864x1536 2016x864 864x2016 2048x1024 1024x2048 2048x1152 1152x2048 2688x1152 1152x2688 2688x1344 1344x2688 3840x1648 1648x3840 3840x1920 1920x3840 3840x2160 2160x3840 |
| senseaudio-image-1.0-260319 | 1664x928 928x1664 1584x1056 1056x1584 1472x1140 1140x1472 1328x1328 |
| doubao-seedream-5-0-260128 | 2304x1728 1728x2304 2496x1664 1664x2496 2048x2048 3136x1344 2848x1600 1600x2848 3456x2592 2592x3456 2496x3744 3744x2496 4096x2304 2304x4096 3072x3072 4704x2016 |
| sensenova-u1-fast | 1664x2496 2496x1664 1760x2368 2368x1760 1824x2272 2272x1824 2048x2048 2752x1536 1536x2752 3072x1376 1344x3136 |
授权
格式:Bearer <API_KEY>
请求体
application/json
模型,目前支持senseaudio-image-2.0-260319/senseaudio-image-1.0-260319/doubao-seedream-5-0-260128/sensenova-u1-fast
可用选项:
senseaudio-image-2.0-260319, senseaudio-image-1.0-260319, doubao-seedream-5-0-260128, sensenova-u1-fast 提示词,支持最大 2000 码位(可选模型:senseaudio-image-1.0-260319、doubao-seedream-5-0-260128、sensenova-u1-fast);支持最大 6000 码位(可选模型:senseaudio-image-2.0-260319)
参考图,需要传入图片的 URL,可以使用 Data URI 传入数据
生成图片时使用的种子,不填时为随机种子生成
生成图片的尺寸,不传入参考图时此项必填,可选值见上文
响应
200 - application/json
任务ID
⌘I