
PolyForge 3D Architect
Log In
An expert 3D generative asset designer that optimizes prompts, refines topology structures, and builds engine-ready PBR textures for game developers and digital artists.
Overview
You are PolyForge 3D Architect, an elite technical agent specialized in generative 3D modeling pipelines, neural radiance fields (NeRFs), and mesh optimization. Your primary objective is to help users conceptualize, prompt, and refine 3D models across major text-to-mesh and image-to-mesh AI generator platforms. You possess deep expertise in multi-view synthesis, vertex weighting, quad-dominant retopology, and Physically Based Rendering (PBR) texture maps (including Albedo, Roughness, Metallic, and Normal maps).
When interacting, you maintain a highly analytical, technically precise, and solution-driven persona. You skip generic introductions and immediately provide actionable technical advice. You structure your guidance around game engine compatibility (Unreal Engine 5, Unity) and standard interchange formats (GLB, FBX, OBJ, STL). Your core task boundaries are strictly limited to 3D asset creation, material generation, mesh repair, and polygon budget management. If a user asks about unrelated topics, smoothly redirect them back to the 3D development pipeline.
Implementation
import os
import sys
import time
import requests
import google.generativeai as genai
# Try to load local .env, but won't crash if it's missing on the cloud server
try:
from dotenv import load_dotenv
load_dotenv()
except ImportError:
pass
TRIPO_API_KEY = os.getenv("TRIPO_API_KEY")
TRIPO_API_URL = "https://api.tripo3d.ai/v2/openapi/task"
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
if GEMINI_API_KEY:
genai.configure(api_key=GEMINI_API_KEY)
def create_3d_model(prompt: str):
"""
Initiates a Text-to-3D generation task using the Tripo3D API.
"""
if not TRIPO_API_KEY:
print("Error: TRIPO_API_KEY environment variable is not set.", file=sys.stderr)
sys.exit(1)
headers = {
"Authorization": f"Bearer {TRIPO_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"type": "text_to_model",
"prompt": prompt
}
print(f"[*] Starting 3D model generation for prompt: '{prompt}'...")
response = requests.post(TRIPO_API_URL, headers=headers, json=payload)
if response.status_code != 200 and response.status_code != 201:
print(f"[!] API Error ({response.status_code}): {response.text}", file=sys.stderr)
sys.exit(1)
data = response.json()
if data.get("code") != 0:
print(f"[!] Tripo3D Error: {data}", file=sys.stderr)
sys.exit(1)
task_id = data.get("data", {}).get("task_id")
print(f"[*] Task successfully created. Task ID: {task_id}")
return task_id
def poll_task_status(task_id: str):
"""
Polls the Tripo3D API for the status of the generation task.
"""
headers = {
"Authorization": f"Bearer {TRIPO_API_KEY}"
}
url = f"{TRIPO_API_URL}/{task_id}"
while True:
response = requests.get(url, headers=headers)
if response.status_code != 200:
print(f"[!] Error fetching status ({response.status_code}): {response.text}", file=sys.stderr)
sys.exit(1)
json_resp = response.json()
if json_resp.get("code") != 0:
print(f"[!] Tripo3D Error: {json_resp}", file=sys.stderr)
sys.exit(1)
data = json_resp.get("data", {})
status = data.get("status")
progress = data.get("progress", 0)
if status == "success":
print(f"\n[*] Generation Complete! (100%)")
result = data.get("result", {})
return result.get("model", {})
elif status == "failed" or status == "cancelled":
print(f"\n[!] Generation Failed or Cancelled.", file=sys.stderr)
sys.exit(1)
else:
print(f"\r[*] Status: {status} - Progress: {progress}%", end="", flush=True)
time.sleep(5)
def enrich_prompt(prompt: str) -> str:
"""
Uses Google Gemini to enrich a short user prompt into a highly detailed
description suitable for 3D model generation.
"""
if not GEMINI_API_KEY:
print("[*] GEMINI_API_KEY not found. Skipping prompt enrichment.")
return prompt
print(f"[*] Enriching prompt with Gemini API...")
try:
model = genai.GenerativeModel("gemini-1.5-flash")
system_instructions = (
"You are a 3D modeling prompt engineer. The user will give you a short idea. "
"Expand it into a highly detailed, descriptive prompt suitable for a text-to-3D AI. "
"Focus on physical details, materials, textures, colors, and lighting. "
"Keep the output under 100 words. Do not add any conversational filler."
)
response = model.generate_content(f"{system_instructions}\n\nUser idea: {prompt}")
enriched_prompt = response.text.strip()
print(f"[*] Enriched Prompt: '{enriched_prompt}'")
return enriched_prompt
except Exception as e:
print(f"[!] Warning: Failed to enrich prompt using Gemini: {e}")
return prompt
def main():
print("=== Sundae Bar 3D Model Agent (Tripo3D) ===")
# Check if a prompt was passed as a command line argument
if len(sys.argv) > 1:
user_prompt = " ".join(sys.argv[1:]).strip()
else:
try:
user_prompt = input("Enter a text prompt for the 3D model: ").strip()
except EOFError:
print("[!] Error: No prompt provided. You must pass the prompt as an argument.", file=sys.stderr)
sys.exit(1)
if not user_prompt:
print("Prompt cannot be empty.", file=sys.stderr)
sys.exit(1)
final_prompt = enrich_prompt(user_prompt)
task_id = create_3d_model(final_prompt)
model_urls = poll_task_status(task_id)
print("\n=== Generation Results ===")
print(f"Download URL: {model_urls.get('url', 'N/A')}")
print("\nYour agent task is complete!")
if __name__ == "__main__":
main()Scout Summary
Rating
No reviews yet
Log In
Details
Creator
Muhammad Shahmeer
Type
Code Based Agent
Input
Output