Imagen4 Image Generation
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>"
}Image Generation - Imagen
Imagen 4
Generate images using Imagen4 model (async)
POST
/
generate
/
k
/
imagen4
Imagen4 Image Generation
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>"
}Generate high-quality images using Google DeepMind’s Imagen 4 model.
Key Features:
- 2K High Resolution - Generate detailed images up to 2K resolution
- Realistic Texture Details - Excellent fabric, water droplet, and animal fur rendering
- Precise Text Typography - Significantly improved text and typography generation
- SynthID Watermark - Built-in invisible digital watermark to identify AI-generated content
Authorizations
Please use your API Token for authentication
Body
application/json
Task parameters
Prompt (required, max 5000 characters)
Required string length:
1 - 5000Example:
"a futuristic cityscape at sunset"
aspect ratio(optional,default 1:1)
Available options:
1:1, 16:9, 9:16, 3:4, 4:3 Example:
"1:1"
Negative prompt (optional)
Example:
"blurry, low quality"
Number of images to generate (optional, 1-4 images, default 1)
Required range:
1 <= x <= 4Example:
1
Random seed (optional, integer type)
Example:
0
Response
OK
Task ID
Example:
"01234567-89ab-cdef-0123-456789abcdef"