Start by buying credits from the available plans here. Your credits will appear on your account page.
On your account page, create a new API key. Save it and keep it in a secure place.
import requests
import random
import numpy as np
RESHOT_API_KEY = "YOUR_API_KEY"
API_URL = "https://api.reshot.ai/v1/face-expressions"
with open("image.jpg", "rb") as image_file:
files = {"file": image_file}
controls = {
"pupil_x": np.clip(np.random.randn(), -1, 1),
"pupil_y": np.clip(np.random.randn(), -1, 1),
"wink": random.choice([True, False]),
"eyes_open": np.clip(np.random.randn(), -1, 0.25),
"eyebrows_up": np.clip(np.random.randn(), -0.65, 1),
"rotate_x": np.clip(np.random.randn(), -1, 1),
"rotate_y": np.clip(np.random.randn(), -1, 1),
"rotate_z": np.clip(np.random.randn(), -1, 1),
"mouth_open_y": np.clip(np.random.randn(), -0.25, 1),
"mouth_open_x": np.clip(np.random.randn(), -1, 0.75),
"smile": np.clip(np.random.randn(), -0.3, 1.3),
}
response = requests.post(API_URL, files=files, data=controls, headers={
"x-api-key": RESHOT_API_KEY,
})
response.raise_for_status()
with open("result.png", "wb") as result_file:
result_file.write(response.content)