import { AtomaSDK } from "atoma-sdk";
const atomaSDK = new AtomaSDK({
bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await atomaSDK.images.generate({
model: "black-forest-labs/FLUX.1-schnell",
prompt: "A cute baby sea otter",
n: 1,
size: "1024x1024"
});
// Handle the result
console.log(result);
}
run();from atoma_sdk import AtomaSDK
import os
with AtomaSDK(
bearer_auth=os.getenv("ATOMASDK_BEARER_AUTH", ""),
) as atoma_sdk:
res = atoma_sdk.images.generate(
model="black-forest-labs/FLUX.1-schnell",
prompt="A cute baby sea otter floating on its back",
n=1,
quality="hd",
response_format="url",
size="1024x1024"
)
print(res)curl --request POST \
--url https://api.atoma.network/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "black-forest-labs/FLUX.1-schnell",
"prompt": "A cute baby sea otter floating on its back",
"n": 1,
"quality": "hd",
"response_format": "url",
"size": "1024x1024",
"style": "vivid",
"user": "user-1234"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'black-forest-labs/FLUX.1-schnell',
prompt: 'A cute baby sea otter floating on its back',
n: 1,
quality: 'hd',
response_format: 'url',
size: '1024x1024',
style: 'vivid',
user: 'user-1234'
})
};
fetch('https://api.atoma.network/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.atoma.network/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([
'model' => 'black-forest-labs/FLUX.1-schnell',
'prompt' => 'A cute baby sea otter floating on its back',
'n' => 1,
'quality' => 'hd',
'response_format' => 'url',
'size' => '1024x1024',
'style' => 'vivid',
'user' => 'user-1234'
]),
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.atoma.network/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"black-forest-labs/FLUX.1-schnell\",\n \"prompt\": \"A cute baby sea otter floating on its back\",\n \"n\": 1,\n \"quality\": \"hd\",\n \"response_format\": \"url\",\n \"size\": \"1024x1024\",\n \"style\": \"vivid\",\n \"user\": \"user-1234\"\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.atoma.network/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"black-forest-labs/FLUX.1-schnell\",\n \"prompt\": \"A cute baby sea otter floating on its back\",\n \"n\": 1,\n \"quality\": \"hd\",\n \"response_format\": \"url\",\n \"size\": \"1024x1024\",\n \"style\": \"vivid\",\n \"user\": \"user-1234\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.atoma.network/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 \"model\": \"black-forest-labs/FLUX.1-schnell\",\n \"prompt\": \"A cute baby sea otter floating on its back\",\n \"n\": 1,\n \"quality\": \"hd\",\n \"response_format\": \"url\",\n \"size\": \"1024x1024\",\n \"style\": \"vivid\",\n \"user\": \"user-1234\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1677649420,
"data": [
{
"url": "https://oaidalleapiprodscus.blob.core.windows.net/private/image.png",
"revised_prompt": "A stunning image of a baby sea otter floating on its back in crystal clear blue water, with gentle ripples surrounding it. The otter's fur appears soft and well-detailed, and its expression is peaceful and content."
}
]
}Create image
This endpoint processes requests to generate images using AI models by forwarding them to the appropriate AI node. The request metadata and compute units have already been validated by middleware before reaching this handler.
Errors
- Returns various status codes based on the underlying
handle_image_generation_response:INTERNAL_SERVER_ERROR- If there’s an error communicating with the AI node
import { AtomaSDK } from "atoma-sdk";
const atomaSDK = new AtomaSDK({
bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await atomaSDK.images.generate({
model: "black-forest-labs/FLUX.1-schnell",
prompt: "A cute baby sea otter",
n: 1,
size: "1024x1024"
});
// Handle the result
console.log(result);
}
run();from atoma_sdk import AtomaSDK
import os
with AtomaSDK(
bearer_auth=os.getenv("ATOMASDK_BEARER_AUTH", ""),
) as atoma_sdk:
res = atoma_sdk.images.generate(
model="black-forest-labs/FLUX.1-schnell",
prompt="A cute baby sea otter floating on its back",
n=1,
quality="hd",
response_format="url",
size="1024x1024"
)
print(res)curl --request POST \
--url https://api.atoma.network/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "black-forest-labs/FLUX.1-schnell",
"prompt": "A cute baby sea otter floating on its back",
"n": 1,
"quality": "hd",
"response_format": "url",
"size": "1024x1024",
"style": "vivid",
"user": "user-1234"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'black-forest-labs/FLUX.1-schnell',
prompt: 'A cute baby sea otter floating on its back',
n: 1,
quality: 'hd',
response_format: 'url',
size: '1024x1024',
style: 'vivid',
user: 'user-1234'
})
};
fetch('https://api.atoma.network/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.atoma.network/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([
'model' => 'black-forest-labs/FLUX.1-schnell',
'prompt' => 'A cute baby sea otter floating on its back',
'n' => 1,
'quality' => 'hd',
'response_format' => 'url',
'size' => '1024x1024',
'style' => 'vivid',
'user' => 'user-1234'
]),
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.atoma.network/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"black-forest-labs/FLUX.1-schnell\",\n \"prompt\": \"A cute baby sea otter floating on its back\",\n \"n\": 1,\n \"quality\": \"hd\",\n \"response_format\": \"url\",\n \"size\": \"1024x1024\",\n \"style\": \"vivid\",\n \"user\": \"user-1234\"\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.atoma.network/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"black-forest-labs/FLUX.1-schnell\",\n \"prompt\": \"A cute baby sea otter floating on its back\",\n \"n\": 1,\n \"quality\": \"hd\",\n \"response_format\": \"url\",\n \"size\": \"1024x1024\",\n \"style\": \"vivid\",\n \"user\": \"user-1234\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.atoma.network/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 \"model\": \"black-forest-labs/FLUX.1-schnell\",\n \"prompt\": \"A cute baby sea otter floating on its back\",\n \"n\": 1,\n \"quality\": \"hd\",\n \"response_format\": \"url\",\n \"size\": \"1024x1024\",\n \"style\": \"vivid\",\n \"user\": \"user-1234\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1677649420,
"data": [
{
"url": "https://oaidalleapiprodscus.blob.core.windows.net/private/image.png",
"revised_prompt": "A stunning image of a baby sea otter floating on its back in crystal clear blue water, with gentle ripples surrounding it. The otter's fur appears soft and well-detailed, and its expression is peaceful and content."
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Request body for image generation
The model to use for image generation.
"black-forest-labs/FLUX.1-schnell"
A text description of the desired image(s). The maximum length is 1000 characters.
"A cute baby sea otter floating on its back"
The number of images to generate. Defaults to 1.
x >= 01
The quality of the image that will be generated.
hd creates images with finer details and greater consistency across the image.
"hd"
The format in which the generated images are returned.
"url"
The size of the generated images.
"1024x1024"
The style of the generated images.
"vivid"
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
"user-1234"