Your First API Generation
Now that you're set up and connected, let's generate your first 3D model through the API. We'll start with the simplest approach and then break it down step by step so you understand what's happening under the hood.
The One-Liner: Generate and Download
The fastest way to go from image to 3D model is the generate_and_download method. It handles everything for you: uploading the image, submitting the generation, polling for completion, and downloading the result.
Python:
1 2 3 4 5 6 7 8 9 10 11 12 | |
JavaScript/TypeScript:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Run this with a real image file and you should see the output file appear after about 20-30 seconds. That's it - you just generated a 3D model from code.
Understanding the Step-by-Step Process
The one-liner is convenient, but understanding the individual steps is important for building more advanced workflows. Let's break it apart.
Step 1: Submit the generation request
When you submit an image, the API uploads it, validates your parameters, deducts credits from your balance, and starts the generation process in the background. It responds immediately with a GenerationResult object.
Python:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
JavaScript/TypeScript:
1 2 3 4 5 6 7 8 9 | |
The generation_uid (or generationUid in JS) is the unique identifier for this specific generation. You'll use it for everything else - checking status, downloading the result, etc. Save it somewhere if you need to come back to it later.
Step 2: Poll for completion
The model takes time to generate (anywhere from 20 seconds to 12 minutes depending on quality). You check the status by polling with the generation UID:
Python:
1 2 3 4 | |
The wait_for_completion method does this polling for you automatically:
1 2 3 4 5 6 7 8 9 10 | |
JavaScript/TypeScript:
1 2 3 4 5 6 | |
Step 3: Download the model
Once the status is "completed", you can download the 3D model file:
Python:
1 2 3 | |
JavaScript/TypeScript:
1 2 | |
Text-to-3D Generation
You can also generate 3D models from text prompts through the API. This works for default, high, and ultra quality levels. (Super and Super+ require an image.)
Python:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
JavaScript/TypeScript:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Behind the scenes, the API converts your text prompt into an image first, then generates the 3D model from that image - exactly like the web app does. This is why text-to-3D is limited to lower quality levels: the super resolution engine requires a direct image input for the best results.
Choosing Quality and Format
Here's a quick guide for choosing the right settings:
Quality selection:
- Use default (4 credits) for quick tests, prototypes, and development
- Use high (6 credits) or ultra (8 credits) for better detail
- Use super (20 credits) for high-resolution geometry when you want production-quality models
- Use superplus (30 credits) for the maximum resolution available
- Add _texture variants when you need colored/textured models (GLB or OBJ format only)
Format selection:
- STL - The standard for 3D printing. Geometry only, no color. Available at all quality levels.
- GLB - Best for web viewers, games, and textured models. Compact binary format.
- OBJ - Widely compatible with 3D software. When using texture quality levels, OBJ returns as a ZIP archive containing the .obj, .mtl, and texture files.
- PLY - Point cloud format. Available for default, high, and ultra quality only.
- FBX - For animation and professional 3D software. Available for super and superplus quality only.
Adding a Progress Callback
For longer generations (especially at super or superplus quality), it's helpful to see progress updates. Both libraries support a callback function that gets called each time the status is polled:
Python:
1 2 3 4 5 6 7 8 9 10 11 | |
JavaScript/TypeScript:
1 2 3 4 5 6 7 8 9 10 | |
This is especially useful during development so you know the generation is making progress and hasn't stalled.