Skip to main content

Quickstart Project

Prerequisites

Minimal Example - Generate from Text Prompt

Python Code:

import base64
import requests
import time

# Get your API key at: https://account.generio.ai → API Keys tab
API_KEY = "your-api-key-here"
BASE_URL = "https://flows.generio.ai"
headers = {"Authorization": f"Bearer {API_KEY}"}

# Define the JSON payload
payload = {
"template": "model_generate_fromprompt",
"parameters": {
"quality": "high"
},
"inputs": [
{
"data": "A modern office chair",
"additional": None
}
],
"additional": None
}

# Create and start flow
response = requests.post(f"{BASE_URL}/flows", headers=headers, json=payload)

if response.status_code != 200:
print(f"Error creating flow: {response.status_code}")
print(response.text)
exit(1)

flow_id = response.json()["flow_id"]
print(f"Flow created: {flow_id}")

# Wait for completion
print("Processing...")
while True:
status_response = requests.get(f"{BASE_URL}/flows/{flow_id}", headers=headers)

if status_response.status_code != 200:
print(f"Error checking status: {status_response.status_code}")
break

status = status_response.json()
state = status['state']
progress = status['progress']

# Progress is 0 (processing) or 1 (finished)
progress_text = "In Progress" if progress == 0 else "Complete"
print(f"Status: {state} - {progress_text}")

if state in ['completed', 'failed', 'aborted']:
break

time.sleep(5)

# Download the 3D model
if status['state'] == 'completed':
outputs_response = requests.get(f"{BASE_URL}/flows/{flow_id}/outputs", headers=headers)

if outputs_response.status_code != 200:
print(f"Error fetching outputs: {outputs_response.status_code}")
exit(1)

outputs = outputs_response.json()["outputs"]

if not outputs:
print("No outputs generated")
exit(1)

for output in outputs:
model_response = requests.get(
f"{BASE_URL}/flows/{flow_id}/outputs/{output['asset_id']}?include_data=true",
headers=headers
)

if model_response.status_code != 200:
print(f"Error downloading output {output['asset_id']}: {model_response.status_code}")
continue

# Parse JSON and decode base64 data
response_json = model_response.json()
data_uri = response_json["data"]

base64_data = data_uri.split(",", 1)[1]
binary_data = base64.b64decode(base64_data)

filename = f"model_{output['asset_id']}.glb"
with open(filename, "wb") as f:
f.write(binary_data)

print(f"✓ Model saved: {filename}")

elif status['state'] == 'failed':
print(f"Flow failed. Error: {status.get('error', 'Unknown error')}")
elif status['state'] == 'aborted':
print("Flow was aborted")

Need an API key? Get one at account.generio.ai → API Keys tab

Need help? Contact us at info@generio.ai or join our Discord server

We appreciate your feedback! If you encounter any errors, bugs, or inconsistencies, please reach out to us :)