import base64
import os
import requests
api_host = os.getenv('API_HOST', 'https://neura-flux.com')
api_key = os.getenv("NEUROFLUX_API_KEY")
if api_key is None:
raise Exception("Missing NeuroFlux API key.")
response = requests.post(
f"{api_host}/v1/ai-service/sdxl",
headers={
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer {api_key}"
},
json={
"text_prompts": [
{
"text": "A lighthouse on a cliff"
}
],
"cfg_scale": 7,
"height": 1024,
"width": 1024,
"samples": 1,
"steps": 30,
},
)
if response.status_code != 200:
raise Exception("Non-200 response: " + str(response.text))
data = response.json()
for i, image in enumerate(data):
with open(f"./out/v1_txt2img_{i}.png", "wb") as f:
f.write(base64.b64decode(image["base64"]))