AI Portrait Generator API
The LightX AI Portrait Generator API goes beyond filters! It blends your regular selfies into artistic portraits. It analyzes facial features and applies style transfer to every element of your photo. It includes the flexibility of text prompts to customize your generations. Fast and Easy!
Create Portraits in Endless Creative Styles and Characters
Change your pictures into cool, painting style photos in seconds!
import requests
url = 'https://api.lightxeditor.com/external/api/v1/portrait'
headers = {
'Content-Type': 'application/json',
'x-api-key': '<Insert your API Key>' # Replace with your actual API key
}
data = {
"imageUrl": "https://example.com/your-image.jpg", # Replace with the URL of your input image
"styleImageUrl": "https://example.com/your-style-image.jpg", # Replace with the URL of your input style image
"textPrompt": "YourInputPrompt" # Replace with your specific input prompt
}
response = requests.post(url, headers=headers, json=data)
# Check if the request was successful
if response.status_code == 200:
print("Request was successful!")
print(response.json())
else:
print(f"Request failed with status code: {response.status_code}")
print(response.text)
const fetch = require('node-fetch'); // Only needed if you are using Node.js
const url = 'https://api.lightxeditor.com/external/api/v1/portrait';
const apiKey = '<Insert your API Key>'; // Replace with your actual API key
const data = {
"imageUrl": "https://example.com/your-image.jpg", // Replace with the URL of your input image
"styleImageUrl": "https://example.com/your-style-image.jpg", // Replace with the URL of your input style image
"textPrompt": "YourInputPrompt" // Replace with your specific input prompt
};
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey
},
body: JSON.stringify(data)
};
fetch(url, options)
.then(response => {
if (!response.ok) {
throw new Error(`Request failed with status code ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('Request was successful!');
console.log(data);
})
.catch(error => {
console.error('Error:', error);
});
}
import Foundation
// Define the URL and API key
let url = URL(string: "https://api.lightxeditor.com/external/api/v1/portrait")!
let apiKey = "<Insert your API Key>" // Replace with your actual API key
// Define the request body
let requestBody: [String: Any] = [
"imageUrl": "https://example.com/your-image.jpg", // Replace with the URL of your input image
"styleImageUrl": "https://example.com/your-style-image.jpg", // Replace with the URL of your input style image
"textPrompt": "YourInputPrompt" // Replace with your specific input prompt
]
// Convert request body to JSON data
let jsonData = try! JSONSerialization.data(withJSONObject: requestBody, options: [])
// Create the URLRequest object
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue(apiKey, forHTTPHeaderField: "x-api-key")
request.httpBody = jsonData
// Create the URLSession data task
let task = URLSession.shared.dataTask(with: request) { data, response, error in
// Handle the response
if let error = error {
print("Error: \(error)")
return
}
guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else {
print("Unexpected response")
return
}
if let data = data {
do {
// Parse and print the JSON response
let jsonResponse = try JSONSerialization.jsonObject(with: data, options: [])
print("Response: \(jsonResponse)")
} catch {
print("Error parsing JSON: \(error)")
}
}
}
// Start the task
task.resume()
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import org.json.JSONObject
fun main() {
// Define the URL and API key
val url = "https://api.lightxeditor.com/external/api/v1/portrait"
val apiKey = "<Insert your API Key>" // Replace with your actual API key
// Define the request body
val requestBody = JSONObject().apply {
put("imageUrl", "https://example.com/your-image.jpg") // Replace with the URL of your input image
put("styleImageUrl", "https://example.com/your-style-image.jpg") // Replace with the URL of your input style image
put("textPrompt", "YourInputPrompt") // Replace with your specific input prompt
}.toString()
// Create OkHttpClient
val client = OkHttpClient()
// Create the request
val request = Request.Builder()
.url(url)
.post(requestBody.toRequestBody("application/json; charset=utf-8".toMediaType()))
.addHeader("x-api-key", apiKey)
.build()
// Make the request
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
throw IOException("Unexpected code $response")
}
// Print the response
val responseData = response.body?.string()
println("Response: $responseData")
}
}
Method- Post
curl --location 'https://api.lightxeditor.com/external/api/v1/portrait' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <Insert your API Key>' \
--data '{
"imageUrl": "https://example.com/your-image.jpg", // Replace with the URL of your input image
"styleImageUrl": "https://example.com/your-style-image.jpg", // Replace with the URL of your input style image
"textPrompt": "YourInputPrompt" // Replace with your specific input prompt
}'
Choose Your Plan
Explore a variety of pricing plans designed to meet your unique requirements. Find the perfect fit and start today.
API for Portrait Transformation: Exaggerate your Look in Photos
AI portraits offer an exaggerated and artistic twist to how you look in photos. It turns photos into portraits in different artistic styles. It lets you experience different versions of your look in a fun and exciting way. It's easier than ever to experiment with your appearance while preserving the core elements of your identity.
Create Custom AI Portraits Based on Prompts
It’s common in all our APIs to include preset styles. But our portrait API can also generate realistic AI portraits based on text prompts. Users can describe the style they want in their photo, including textures, colors, artistic styles, etc. The AI portrait is not just a basic filter overlay; it's generative AI that creates a new version of your photo based on prompts or even predefined styles.
Changes Outfits, Hair, Backgrounds: Keeps Face Intact
The tool is trained to create a lifelike character that makes you look like you. This means that the tool will not only adapt the colors of a character you can also experiment with different outfits, hairstyles, and backgrounds, all without altering your facial features.
Start with Free Credits
Get started with LightX APIs today! Receive 25 free credits instantly on API signup – no credit card required
Frequently Asked Questions
The API works by first analyzing a well-lit, in-focus photo you upload in JPEG or PNG format. You can then describe your desired style through a text prompt or select from premade styles. After that, the API creates an HD portrait based on the input and lets you download the final result to your device.
Still Unsure? Allow Us To Assist You!
Write to us and we'd love to understand your requirements