Imagen4 图片生成
curl --request POST \
--url https://api.sinancode.com/v1/generate/k/imagen4 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "a futuristic cityscape at sunset",
"aspect_ratio": "1:1",
"negative_prompt": "blurry, low quality",
"num_images": 1,
"seed": 0
}
'import requests
url = "https://api.sinancode.com/v1/generate/k/imagen4"
payload = {
"prompt": "a futuristic cityscape at sunset",
"aspect_ratio": "1:1",
"negative_prompt": "blurry, low quality",
"num_images": 1,
"seed": 0
}
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: 'a futuristic cityscape at sunset',
aspect_ratio: '1:1',
negative_prompt: 'blurry, low quality',
num_images: 1,
seed: 0
})
};
fetch('https://api.sinancode.com/v1/generate/k/imagen4', 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.sinancode.com/v1/generate/k/imagen4",
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' => 'a futuristic cityscape at sunset',
'aspect_ratio' => '1:1',
'negative_prompt' => 'blurry, low quality',
'num_images' => 1,
'seed' => 0
]),
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.sinancode.com/v1/generate/k/imagen4"
payload := strings.NewReader("{\n \"prompt\": \"a futuristic cityscape at sunset\",\n \"aspect_ratio\": \"1:1\",\n \"negative_prompt\": \"blurry, low quality\",\n \"num_images\": 1,\n \"seed\": 0\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.sinancode.com/v1/generate/k/imagen4")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"a futuristic cityscape at sunset\",\n \"aspect_ratio\": \"1:1\",\n \"negative_prompt\": \"blurry, low quality\",\n \"num_images\": 1,\n \"seed\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sinancode.com/v1/generate/k/imagen4")
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\": \"a futuristic cityscape at sunset\",\n \"aspect_ratio\": \"1:1\",\n \"negative_prompt\": \"blurry, low quality\",\n \"num_images\": 1,\n \"seed\": 0\n}"
response = http.request(request)
puts response.read_body{
"task_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}图片生成 - Imagen
Imagen 4
使用 Imagen4 模型生成图片(异步)
POST
/
generate
/
k
/
imagen4
Imagen4 图片生成
curl --request POST \
--url https://api.sinancode.com/v1/generate/k/imagen4 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "a futuristic cityscape at sunset",
"aspect_ratio": "1:1",
"negative_prompt": "blurry, low quality",
"num_images": 1,
"seed": 0
}
'import requests
url = "https://api.sinancode.com/v1/generate/k/imagen4"
payload = {
"prompt": "a futuristic cityscape at sunset",
"aspect_ratio": "1:1",
"negative_prompt": "blurry, low quality",
"num_images": 1,
"seed": 0
}
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: 'a futuristic cityscape at sunset',
aspect_ratio: '1:1',
negative_prompt: 'blurry, low quality',
num_images: 1,
seed: 0
})
};
fetch('https://api.sinancode.com/v1/generate/k/imagen4', 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.sinancode.com/v1/generate/k/imagen4",
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' => 'a futuristic cityscape at sunset',
'aspect_ratio' => '1:1',
'negative_prompt' => 'blurry, low quality',
'num_images' => 1,
'seed' => 0
]),
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.sinancode.com/v1/generate/k/imagen4"
payload := strings.NewReader("{\n \"prompt\": \"a futuristic cityscape at sunset\",\n \"aspect_ratio\": \"1:1\",\n \"negative_prompt\": \"blurry, low quality\",\n \"num_images\": 1,\n \"seed\": 0\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.sinancode.com/v1/generate/k/imagen4")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"a futuristic cityscape at sunset\",\n \"aspect_ratio\": \"1:1\",\n \"negative_prompt\": \"blurry, low quality\",\n \"num_images\": 1,\n \"seed\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sinancode.com/v1/generate/k/imagen4")
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\": \"a futuristic cityscape at sunset\",\n \"aspect_ratio\": \"1:1\",\n \"negative_prompt\": \"blurry, low quality\",\n \"num_images\": 1,\n \"seed\": 0\n}"
response = http.request(request)
puts response.read_body{
"task_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}使用 Google DeepMind 的 Imagen 4 模型生成高质量图片。
模型特点:
- 2K 高分辨率 - 支持生成高达 2K 分辨率的精细图像
- 逼真纹理细节 - 出色的织物、水滴、动物毛发等材质渲染
- 精准文字排版 - 显著改进的文字和排版生成能力
- SynthID 水印 - 内置隐形数字水印,可识别 AI 生成内容
授权
请使用您的 API Token 进行认证
请求体
application/json
任务参数
提示词(必填,最大5000字符)
Required string length:
1 - 5000示例:
"a futuristic cityscape at sunset"
宽高比(可选,默认 1:1)
可用选项:
1:1, 16:9, 9:16, 3:4, 4:3 示例:
"1:1"
反向提示词(可选)
示例:
"blurry, low quality"
生成图片数量(可选,1-4张,默认1)
必填范围:
1 <= x <= 4示例:
1
随机种子(可选,整数类型)
示例:
0
响应
OK
Task ID
示例:
"01234567-89ab-cdef-0123-456789abcdef"
⌘I