import json
import requests
def main():
api_key = "YOUR_API_KEY"
model_id = "MODEL_ID"
payload = {
"subject_image": "<base64_image_string_here>",
"prompt": "Make the cubes pink",
"remove_bg": False,
"matting": False,
"steps": 8,
"strength_sub": 1.0,
"strength_spat": 1.0,
"size": 1024,
"rank": 3.0,
"bg_detail_cutoff": 3,
"blend_mode": "Detail-preserving",
}
resp = requests.post(
f"https://model-{model_id}.api.baseten.co/environments/production/predict",
headers={"Authorization": f"Api-Key {api_key}"},
json=payload
)
resp.raise_for_status()
response_dict = json.loads(resp.text)
for i in response_dict:
print("key: ", i, "val: ", response_dict[i])
with open('b64.txt', 'w') as f:
f.write(response_dict["blended"])
if __name__ == "__main__":
main()