import os
import requests
# Constants
ENDPOINT = "https://api.hyper3d.com/api/v2/bang"
API_KEY = "your api key" # Replace with your actual API key
UUID = "Your_UUID" # Replace with the UUID of your Rodin Gen-2 Generation Task
IMAGE_PATH = "Your_Image" # Replace with the path of your image
MODEL_PATH = "Your_Model" # Replace with the path of your 3d model
# Prepare the files
# Read the image file
with open(IMAGE_PATH, 'rb') as image_file:
image_data = image_file.read()
with open(MODEL_PATH, 'rb') as model_file:
model_data = model_file.read()
# Prepare the multipart form data
files = {
'image': (os.path.basename(IMAGE_PATH), image_data, 'image/jpeg'),
'model': (os.path.basename(IMAGE_PATH), model_data, 'application/octet-stream'),
}
# Prepare the data
data = {
'prompt': "prompt reference."
'strength': 5,
'geometry_file_format': 'glb',
'material': 'PBR',
'resolution': 'Basic',
}
# Prepare the headers
headers = {
'Authorization': f'Bearer {API_KEY}',
}
# Make the POST request
response = requests.post(ENDPOINT, data = data, files = files, headers=headers)
# Check if request was successful
if response.status_code == 200:
# Parse and print the JSON response
result = response.json()
print("Success! Task submitted:")
print(f"Task UUID: {result.get('uuid')}")
else:
print(f"Error: {response.status_code}")
print(response.text)