API Documentation

Avatar

API documentation and implementation examples for the Avatar model.

Part of the Image To Image / Avatar collection

API Endpoint

/v1/image-to-image/avatar

Request Parameters

enable_safety_checkerbooleanDefault: true

Optional flag to enable content safety checking

face_image_url(Required)string

URL to a face image to be used in generation

prompt(Required)string

Text prompt describing the desired image

seedinteger

Optional seed value for reproducible generation

Code Examples

const apiKey = "YOUR_API_KEY"; fetch("https://api.stockimg.ai/v1/image-to-image/avatar", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${apiKey}` }, body: JSON.stringify({ "enable_safety_checker": true, "face_image_url": "example string", "prompt": "example string", "seed": 1 }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));

Response Example

{ "has_nsfw_concepts": [ true ], "images": [ { "content_type": "example string", "file_data": "example string", "file_name": "example string", "file_size": 1, "height": 1, "url": "example string", "width": 1 } ], "prompt": "example string", "seed": 1, "timings": { "inference": 1 } }

Response Fields

has_nsfw_concepts(Required)array [boolean]

Array of flags indicating NSFW content detection for each image

images(Required)array [object]

Array of generated images

Array items:
[item]object
content_typestring

MIME type of the image

file_datastring

Optional base64 encoded image data

file_namestring

Name of the generated image file

file_sizeinteger

Size of the image file in bytes

heightinteger

Height of the image in pixels

urlstring

URL to access the generated image

widthinteger

Width of the image in pixels

prompt(Required)string

The original prompt used for generation

seed(Required)integer

Seed value used for this generation

timings(Required)object

Performance metrics for the generation process

inferencenumber

Time taken for inference in seconds