import { AtomaSDK } from "atoma-sdk";
const atomaSDK = new AtomaSDK({
bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await atomaSDK.confidentialImages.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.confidential_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/confidential/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ciphertext": "<string>",
"client_dh_public_key": "<string>",
"model_name": "<string>",
"node_dh_public_key": "<string>",
"nonce": "<string>",
"plaintext_body_hash": "<string>",
"salt": "<string>",
"stack_small_id": 1,
"num_compute_units": 1,
"stream": true
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ciphertext: '<string>',
client_dh_public_key: '<string>',
model_name: '<string>',
node_dh_public_key: '<string>',
nonce: '<string>',
plaintext_body_hash: '<string>',
salt: '<string>',
stack_small_id: 1,
num_compute_units: 1,
stream: true
})
};
fetch('https://api.atoma.network/v1/confidential/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/confidential/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([
'ciphertext' => '<string>',
'client_dh_public_key' => '<string>',
'model_name' => '<string>',
'node_dh_public_key' => '<string>',
'nonce' => '<string>',
'plaintext_body_hash' => '<string>',
'salt' => '<string>',
'stack_small_id' => 1,
'num_compute_units' => 1,
'stream' => true
]),
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/confidential/images/generations"
payload := strings.NewReader("{\n \"ciphertext\": \"<string>\",\n \"client_dh_public_key\": \"<string>\",\n \"model_name\": \"<string>\",\n \"node_dh_public_key\": \"<string>\",\n \"nonce\": \"<string>\",\n \"plaintext_body_hash\": \"<string>\",\n \"salt\": \"<string>\",\n \"stack_small_id\": 1,\n \"num_compute_units\": 1,\n \"stream\": true\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/confidential/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ciphertext\": \"<string>\",\n \"client_dh_public_key\": \"<string>\",\n \"model_name\": \"<string>\",\n \"node_dh_public_key\": \"<string>\",\n \"nonce\": \"<string>\",\n \"plaintext_body_hash\": \"<string>\",\n \"salt\": \"<string>\",\n \"stack_small_id\": 1,\n \"num_compute_units\": 1,\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.atoma.network/v1/confidential/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 \"ciphertext\": \"<string>\",\n \"client_dh_public_key\": \"<string>\",\n \"model_name\": \"<string>\",\n \"node_dh_public_key\": \"<string>\",\n \"nonce\": \"<string>\",\n \"plaintext_body_hash\": \"<string>\",\n \"salt\": \"<string>\",\n \"stack_small_id\": 1,\n \"num_compute_units\": 1,\n \"stream\": true\n}"
response = http.request(request)
puts response.read_body{
"ciphertext": "<string>",
"nonce": "<string>",
"response_hash": "<string>",
"signature": "<string>",
"usage": {
"completion_tokens": 10,
"completion_tokens_details": {
"accepted_prediction_tokens": 10,
"audio_tokens": 0,
"reasoning_tokens": 10,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 10,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 10
},
"total_tokens": 20
}
}Create confidential image
This handler processes image generation requests in a confidential manner, providing additional encryption and security measures for sensitive data processing. It supports both streaming and non-streaming responses while maintaining data confidentiality through AEAD encryption and TEE hardware, for full private AI compute.
import { AtomaSDK } from "atoma-sdk";
const atomaSDK = new AtomaSDK({
bearerAuth: process.env["ATOMASDK_BEARER_AUTH"] ?? "",
});
async function run() {
const result = await atomaSDK.confidentialImages.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.confidential_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/confidential/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ciphertext": "<string>",
"client_dh_public_key": "<string>",
"model_name": "<string>",
"node_dh_public_key": "<string>",
"nonce": "<string>",
"plaintext_body_hash": "<string>",
"salt": "<string>",
"stack_small_id": 1,
"num_compute_units": 1,
"stream": true
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ciphertext: '<string>',
client_dh_public_key: '<string>',
model_name: '<string>',
node_dh_public_key: '<string>',
nonce: '<string>',
plaintext_body_hash: '<string>',
salt: '<string>',
stack_small_id: 1,
num_compute_units: 1,
stream: true
})
};
fetch('https://api.atoma.network/v1/confidential/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/confidential/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([
'ciphertext' => '<string>',
'client_dh_public_key' => '<string>',
'model_name' => '<string>',
'node_dh_public_key' => '<string>',
'nonce' => '<string>',
'plaintext_body_hash' => '<string>',
'salt' => '<string>',
'stack_small_id' => 1,
'num_compute_units' => 1,
'stream' => true
]),
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/confidential/images/generations"
payload := strings.NewReader("{\n \"ciphertext\": \"<string>\",\n \"client_dh_public_key\": \"<string>\",\n \"model_name\": \"<string>\",\n \"node_dh_public_key\": \"<string>\",\n \"nonce\": \"<string>\",\n \"plaintext_body_hash\": \"<string>\",\n \"salt\": \"<string>\",\n \"stack_small_id\": 1,\n \"num_compute_units\": 1,\n \"stream\": true\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/confidential/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ciphertext\": \"<string>\",\n \"client_dh_public_key\": \"<string>\",\n \"model_name\": \"<string>\",\n \"node_dh_public_key\": \"<string>\",\n \"nonce\": \"<string>\",\n \"plaintext_body_hash\": \"<string>\",\n \"salt\": \"<string>\",\n \"stack_small_id\": 1,\n \"num_compute_units\": 1,\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.atoma.network/v1/confidential/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 \"ciphertext\": \"<string>\",\n \"client_dh_public_key\": \"<string>\",\n \"model_name\": \"<string>\",\n \"node_dh_public_key\": \"<string>\",\n \"nonce\": \"<string>\",\n \"plaintext_body_hash\": \"<string>\",\n \"salt\": \"<string>\",\n \"stack_small_id\": 1,\n \"num_compute_units\": 1,\n \"stream\": true\n}"
response = http.request(request)
puts response.read_body{
"ciphertext": "<string>",
"nonce": "<string>",
"response_hash": "<string>",
"signature": "<string>",
"usage": {
"completion_tokens": 10,
"completion_tokens_details": {
"accepted_prediction_tokens": 10,
"audio_tokens": 0,
"reasoning_tokens": 10,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 10,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 10
},
"total_tokens": 20
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
A request for confidential computation that includes encrypted data and associated cryptographic parameters
The encrypted payload that needs to be processed (base64 encoded)
Client's public key for Diffie-Hellman key exchange (base64 encoded)
Model name
Node's public key for Diffie-Hellman key exchange (base64 encoded)
Cryptographic nonce used for encryption (base64 encoded)
Hash of the original plaintext body for integrity verification (base64 encoded)
Salt value used in key derivation (base64 encoded)
Unique identifier for the small stack being used
x >= 0Number of compute units to be used for the request, for image generations, as this value is known in advance (the number of pixels to generate)
x >= 0Indicates whether this is a streaming request
Response
Image generations
Represents a response from a confidential compute request
Encrypted response body (base64 encoded)
Nonce used for encryption (base64 encoded)
Hash of the response body (base64 encoded)
Signature of the response body (base64 encoded)
Usage statistics for the request
Show child attributes
Show child attributes