Server-side quickstart: submit, poll, save a GLB
Discover the public model catalog without signing in. It currently lists five mode/quality combinations. Submit mode and quality, not a catalog ID or an upstream model name. Self-serve keys allow standard and pro; the catalog's Ultra entry does not grant Ultra access.
For images, send base64 bytes in JSON image (or image_base64), or a multipart image/file upload. An image_url field is not supported. Text mode uses prompt. The beta returns GLB; there is no output_format switch for OBJ or STL.
curl · shell environment variables · paid commands clearly marked
# Public discovery: no key or generation charge.
curl --fail-with-body https://image3d.io/api/v1/models
# Paid text submission; set IMAGE3D_API_KEY in your server environment first.
curl --fail-with-body https://image3d.io/api/v1/generations \
-H "Authorization: Bearer $IMAGE3D_API_KEY" \
-H "Content-Type: application/json" \
--data '{"mode":"text","quality":"standard","prompt":"A small stone castle"}'
# Save the returned id as IMAGE3D_TASK_ID. This GET can settle billing.
curl --fail-with-body \
"https://image3d.io/api/v1/generations/$IMAGE3D_TASK_ID" \
-H "Authorization: Bearer $IMAGE3D_API_KEY"
For an image workflow, save the Python 3 standard-library example below as image3d_quickstart.py. Set IMAGE3D_API_KEY securely in the server environment, then run python image3d_quickstart.py input.png. This submits one paid Standard image job. To resume, set IMAGE3D_TASK_ID to the saved ID and use the same key; no image argument or new submission is needed.
Show complete Python image → task → GLB example
import base64
import json
import os
import struct
import sys
import time
import urllib.error
import urllib.parse
import urllib.request
from pathlib import Path
BASE = "https://image3d.io"
KEY = os.environ["IMAGE3D_API_KEY"] # Server-side only; never embed in a browser.
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
api = urllib.request.build_opener(NoRedirect)
def api_json(path, payload=None):
data = json.dumps(payload).encode() if payload is not None else None
request = urllib.request.Request(BASE + path, data=data, headers={
"Authorization": "Bearer " + KEY,
"Content-Type": "application/json",
})
try:
with api.open(request, timeout=30) as response:
return json.load(response)
except (urllib.error.URLError, TimeoutError, ValueError) as error:
code = getattr(error, "code", "transport/JSON")
raise SystemExit(f"API error {code}. Stop and inspect; do not blindly resubmit a paid POST.")
def main():
task_id = os.environ.get("IMAGE3D_TASK_ID")
if not task_id:
image = Path(sys.argv[1]).read_bytes() # PNG or JPEG you may use.
mime = "image/png" if image.startswith(b"\x89PNG\r\n\x1a\n") else "image/jpeg" if image.startswith(b"\xff\xd8\xff") else None
if not mime:
raise SystemExit("Use a PNG or JPEG image")
task = api_json("/api/v1/generations", {
"mode": "image", "quality": "standard",
"image": "data:" + mime + ";base64," + base64.b64encode(image).decode("ascii"),
}) # One paid submission only; this example does not retry POST.
task_id = task["id"]
print("Save this task ID to resume polling:", task_id, flush=True)
if not task_id or any(c not in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-" for c in task_id):
raise SystemExit("Invalid task ID")
# Resume with the SAME API key and IMAGE3D_TASK_ID, without a new POST.
deadline = time.monotonic() + 600
while time.monotonic() < deadline:
task = api_json("/api/v1/generations/" + task_id)
if task.get("status") == "failed":
raise SystemExit("Generation failed; inspect charged_credits and refunded_credits.")
if task.get("status") == "success":
break
if task.get("status") not in ("queued", "pending", "processing", "running"):
raise SystemExit("Unknown status; stop and inspect the saved task.")
time.sleep(5)
else:
raise SystemExit("Polling deadline reached. Resume this task later; do not submit it again.")
print({k: task.get(k) for k in ("precharged_credits", "charged_credits", "refunded_credits")})
if not task.get("model_url"):
raise SystemExit("Success without model_url; inspect the saved task.")
url = urllib.parse.urljoin(BASE, task["model_url"])
if urllib.parse.urlsplit(url).scheme != "https":
raise SystemExit("Expected an HTTPS model URL")
# Asset requests NEVER receive the API key, even for a different host.
with urllib.request.urlopen(url, timeout=60) as response:
data = response.read(256 * 1024 * 1024 + 1) # Local example size limit.
if len(data) > 256 * 1024 * 1024 or len(data) < 12:
raise SystemExit("Unexpected model size")
magic, version, length = struct.unpack("<4sII", data[:12])
if magic != b"glTF" or version != 2 or length != len(data):
raise SystemExit("Output is not a complete GLB 2 container")
output = Path(task_id + ".glb")
with output.open("xb") as file: # Preserve an existing local file.
file.write(data)
print("Saved", output, "— inspect geometry before use.")
if __name__ == "__main__":
main()
The 10-minute polling deadline is a client example limit, not a completion-time promise. Terminal states are success and failed. Stop on API errors: 401 means missing/invalid key; 403 means disabled key or disallowed quality; 402 means insufficient credits; 429 means concurrency/billing contention; 404 may mean the wrong key, an unknown task or expired task metadata. Do not automatically resubmit after an uncertain response.
Task records currently expire after 180 days, but this is not a 180-day output-storage guarantee. Download a successful model_url promptly; it can be relative or an external HTTPS URL. Never send your API key to that asset URL. The example checks the GLB 2 container header and byte length; this does not validate geometry, rights, rigging or print readiness. Status polling may finalize charges/refunds and is not a strictly read-only billing operation.
API and Studio use the same eligible subscription/purchased credit balance, with different per-job charges. A single 1,000-credit Maker purchase alone does not meet the 2,000-credit new-key threshold. Free-trial-only balance is not API funding. Subscription allowances follow their billing cycle and do not roll over; check your current credit terms before funding.
For agents, give the caller this quickstart, the API reference, public model list and site discovery file. The model list is not a complete request JSON Schema. Image3D does not offer a public upstream-model marketplace, rigging, motion generation, world-video generation or a verified MCP integration through this API.