Create image generation
Generates one or more images from a text prompt.
POST
/
images
/
generations
Create image generation
curl --request POST \
--url https://api.neosantara.xyz/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "A beautiful sunset over the mountains in an anime art style.",
"n": 1,
"size": "1024x1024",
"model": "neosantara-gen-2045"
}
'import requests
url = "https://api.neosantara.xyz/v1/images/generations"
payload = {
"prompt": "A beautiful sunset over the mountains in an anime art style.",
"n": 1,
"size": "1024x1024",
"model": "neosantara-gen-2045"
}
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 beautiful sunset over the mountains in an anime art style.',
n: 1,
size: '1024x1024',
model: 'neosantara-gen-2045'
})
};
fetch('https://api.neosantara.xyz/v1/images/generations', 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.neosantara.xyz/v1/images/generations",
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 beautiful sunset over the mountains in an anime art style.',
'n' => 1,
'size' => '1024x1024',
'model' => 'neosantara-gen-2045'
]),
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.neosantara.xyz/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"A beautiful sunset over the mountains in an anime art style.\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"model\": \"neosantara-gen-2045\"\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.neosantara.xyz/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"A beautiful sunset over the mountains in an anime art style.\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"model\": \"neosantara-gen-2045\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.neosantara.xyz/v1/images/generations")
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 beautiful sunset over the mountains in an anime art style.\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"model\": \"neosantara-gen-2045\"\n}"
response = http.request(request)
puts response.read_body{
"id": "img-12345",
"object": "image",
"created": 1717950000,
"model": "neosantara-gen-2045",
"data": [
{
"url": "https://example.com/image.png",
"b64_json": null
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 8,
"total_tokens": 23
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "invalid_parameter",
"param": "<string>",
"details": {}
},
"info_metadata": {
"creator": "noesantara.xyz",
"status": true,
"timestamp": "2023-11-07T05:31:56Z",
"request_id": "<string>",
"processing_time": 123,
"tier": "<string>",
"user_total_usage": {
"used": 123,
"limit": 123,
"remaining": 123,
"reset_at": "2023-11-07T05:31:56Z"
}
}
}{
"error": {
"message": "<string>",
"type": "auth_error",
"code": "invalid_api_key",
"details": {}
},
"info_metadata": {
"creator": "noesantara.xyz",
"status": true,
"timestamp": "2023-11-07T05:31:56Z",
"request_id": "<string>",
"processing_time": 123,
"tier": "<string>",
"user_total_usage": {
"used": 123,
"limit": 123,
"remaining": 123,
"reset_at": "2023-11-07T05:31:56Z"
}
}
}{
"error": {
"message": "<string>",
"type": "rate_limit_exceeded",
"code": "rpm_exceeded",
"details": {
"limit": 123,
"remaining": 123,
"reset": "2023-11-07T05:31:56Z",
"retry_after": 123
}
},
"info_metadata": {
"creator": "noesantara.xyz",
"status": true,
"timestamp": "2023-11-07T05:31:56Z",
"request_id": "<string>",
"processing_time": 123,
"tier": "<string>",
"user_total_usage": {
"used": 123,
"limit": 123,
"remaining": 123,
"reset_at": "2023-11-07T05:31:56Z"
}
}
}{
"error": {
"message": "<string>",
"type": "server_error",
"code": "internal_error",
"details": {}
},
"info_metadata": {
"creator": "noesantara.xyz",
"status": true,
"timestamp": "2023-11-07T05:31:56Z",
"request_id": "<string>",
"processing_time": 123,
"tier": "<string>",
"user_total_usage": {
"used": 123,
"limit": 123,
"remaining": 123,
"reset_at": "2023-11-07T05:31:56Z"
}
}
}Authorizations
Your NeosantaraAI API Key.
Body
application/json
The model to use for image generation.
A text description of the desired image(s). The maximum length is 1000 characters.
The number of images to generate.
Required range:
1 <= x <= 4The size of the generated images.
Available options:
256x256, 512x512, 1024x1024 The format in which the generated images are returned.
Available options:
url, b64_json The number of inference steps to perform.
Required range:
1 <= x <= 50Response
Image generation result
A unique identifier for the image generation request.
The type of object returned.
Example:
"image"
The timestamp of when the image was created.
The model used for the image generation.
A list of generated image objects.
- Option 1
- Option 2
Show child attributes
Show child attributes
Token usage information for the request.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
⌘I
Create image generation
curl --request POST \
--url https://api.neosantara.xyz/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "A beautiful sunset over the mountains in an anime art style.",
"n": 1,
"size": "1024x1024",
"model": "neosantara-gen-2045"
}
'import requests
url = "https://api.neosantara.xyz/v1/images/generations"
payload = {
"prompt": "A beautiful sunset over the mountains in an anime art style.",
"n": 1,
"size": "1024x1024",
"model": "neosantara-gen-2045"
}
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 beautiful sunset over the mountains in an anime art style.',
n: 1,
size: '1024x1024',
model: 'neosantara-gen-2045'
})
};
fetch('https://api.neosantara.xyz/v1/images/generations', 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.neosantara.xyz/v1/images/generations",
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 beautiful sunset over the mountains in an anime art style.',
'n' => 1,
'size' => '1024x1024',
'model' => 'neosantara-gen-2045'
]),
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.neosantara.xyz/v1/images/generations"
payload := strings.NewReader("{\n \"prompt\": \"A beautiful sunset over the mountains in an anime art style.\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"model\": \"neosantara-gen-2045\"\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.neosantara.xyz/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"A beautiful sunset over the mountains in an anime art style.\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"model\": \"neosantara-gen-2045\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.neosantara.xyz/v1/images/generations")
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 beautiful sunset over the mountains in an anime art style.\",\n \"n\": 1,\n \"size\": \"1024x1024\",\n \"model\": \"neosantara-gen-2045\"\n}"
response = http.request(request)
puts response.read_body{
"id": "img-12345",
"object": "image",
"created": 1717950000,
"model": "neosantara-gen-2045",
"data": [
{
"url": "https://example.com/image.png",
"b64_json": null
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 8,
"total_tokens": 23
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "invalid_parameter",
"param": "<string>",
"details": {}
},
"info_metadata": {
"creator": "noesantara.xyz",
"status": true,
"timestamp": "2023-11-07T05:31:56Z",
"request_id": "<string>",
"processing_time": 123,
"tier": "<string>",
"user_total_usage": {
"used": 123,
"limit": 123,
"remaining": 123,
"reset_at": "2023-11-07T05:31:56Z"
}
}
}{
"error": {
"message": "<string>",
"type": "auth_error",
"code": "invalid_api_key",
"details": {}
},
"info_metadata": {
"creator": "noesantara.xyz",
"status": true,
"timestamp": "2023-11-07T05:31:56Z",
"request_id": "<string>",
"processing_time": 123,
"tier": "<string>",
"user_total_usage": {
"used": 123,
"limit": 123,
"remaining": 123,
"reset_at": "2023-11-07T05:31:56Z"
}
}
}{
"error": {
"message": "<string>",
"type": "rate_limit_exceeded",
"code": "rpm_exceeded",
"details": {
"limit": 123,
"remaining": 123,
"reset": "2023-11-07T05:31:56Z",
"retry_after": 123
}
},
"info_metadata": {
"creator": "noesantara.xyz",
"status": true,
"timestamp": "2023-11-07T05:31:56Z",
"request_id": "<string>",
"processing_time": 123,
"tier": "<string>",
"user_total_usage": {
"used": 123,
"limit": 123,
"remaining": 123,
"reset_at": "2023-11-07T05:31:56Z"
}
}
}{
"error": {
"message": "<string>",
"type": "server_error",
"code": "internal_error",
"details": {}
},
"info_metadata": {
"creator": "noesantara.xyz",
"status": true,
"timestamp": "2023-11-07T05:31:56Z",
"request_id": "<string>",
"processing_time": 123,
"tier": "<string>",
"user_total_usage": {
"used": 123,
"limit": 123,
"remaining": 123,
"reset_at": "2023-11-07T05:31:56Z"
}
}
}