How to Build 3D Apps with AI Tools and the Neural4D API

Published: Jun 17, 2026
6 min read

1. Building Automations and Apps with AI Tools

What are ChatGPT and Gemini? They are AI tools that can draft and explain code from natural language instructions. Give them the current Neural4D Text-to-3D API reference to help draft a Python or Node.js script that creates a model. The API Quickstart explains authentication and the asynchronous result workflow. Review and test any generated code before using it.

You can adapt this workflow for a custom 3D application, a Discord bot, or an automated content pipeline. Check the resulting asset against your project's requirements before using it in a finished product.

Looking for frontend development instead? If you prefer to generate models manually and use Gemini to write the display code (like Three.js), check out our Guide to Building Interactive 3D Websites or watch the video tutorial below:

Need direct code integration? For developers looking to write their own backend scripts manually without AI tools, see our dedicated guide on How to Integrate Neural4D API into Custom Workflows.

2. How to prepare your Neural4D API key?

Before running a script, you need an API key for Bearer authentication. For a detailed walkthrough, check out our guide on How to Get and Manage Your Neural4D API Key.

Step 1 Log in to the Neural4D Studio.
Step 2 Click the API icon at the bottom of the left sidebar.
Step 3 Click Create API Key and enter a label for the key.
Step 4 Click Confirm, then store the key securely.

Keep your key out of AI chats, public repositories, and client-side code. The script below will read it from a local environment variable.

3. How to prompt an AI tool for a 3D generation script?

Give the AI tool the current API reference and the request flow below. Copy this prompt as written. Keep your real API key on your computer and never paste it into the chat.

prompt
Write a Python script using requests to generate one 3D model with the Neural4D API. Follow the current documentation: https://docs.neural4d.com/en/api-reference/text-to-3d/generate-model-from-text https://docs.neural4d.com/en/api-reference/model-management/retrieve-model 1. Read the API key from the NEURAL4D_API_KEY environment variable. If it is missing, show a clear error. Never print or hard-code the key. 2. Build the Authorization header as Bearer plus the key read from NEURAL4D_API_KEY. Send POST https://alb.neural4d.com:3000/api/generateModelWithText with Content-Type: application/json. Use JSON: {"prompt": "A futuristic sci-fi helmet", "modelCount": 1}. 3. Check the HTTP response and API errors. Save the first UUID from the response's "uuids" array. 4. Poll POST https://alb.neural4d.com:3000/api/retrieveModel with JSON {"uuid": saved_uuid} and the same headers. Use a configurable interval and a maximum wait time. 5. In the retrieval response, "codeStatus" 1 means generating and 0 means complete. Handle -1 (invalid or expired token), -2 (unknown UUID), and -3 (generation failed) as errors. 6. When complete, download the asset from "modelUrl" and preserve its file extension when available. Do not assume the result is an OBJ file. 7. Add request timeouts, helpful error messages, and comments explaining how to run the script.

Review the generated script against the linked API pages before running it. If you need an OBJ file, use the separate model format conversion API after generation. Format conversion consumes points.

4. How to test the generated script in your terminal?

Once ChatGPT or Gemini provides the Python script, review it and then follow these steps:

  • Save the provided code to a file named generate_3d.py on your computer.
  • Open your terminal (Command Prompt on Windows, or Terminal on macOS/Linux).
  • Install the requests library with pip install requests.
  • Set NEURAL4D_API_KEY locally to your API key. In PowerShell, use $env:NEURAL4D_API_KEY="your_key". In Command Prompt, use set NEURAL4D_API_KEY=your_key. On macOS or Linux, use export NEURAL4D_API_KEY="your_key".
  • Run python generate_3d.py. The script should query the job until it completes, fails, or reaches its configured timeout.
  • Check the downloaded model and its file format. The current API documentation shows a GLB result; use format conversion if your project requires OBJ or another format.

5. What are the common errors when using AI-generated scripts?

Check the HTTP response and the API response body when a request fails:

401 or codeStatus -1 Check that NEURAL4D_API_KEY is set and that the key is valid. Generate a new key if the old one has expired or been revoked.
400 Bad Request Check the JSON field names and values against the current text-to-3D reference.
402 or 403 Check your account balance, permissions, and any account restrictions.
429 Too Many Requests Wait before retrying, and reduce how often the script sends requests.
Moderation response A generation request can return a moderation message instead of a uuids array. Read the message and revise the prompt.
codeStatus -2 or -3 Confirm the UUID came from the create response. A value of -2 means it was not found; -3 means generation failed.
ModuleNotFoundError Install the Python requests library with pip install requests.
Script timeout The task may still be running. Check the job progress endpoint or try again with a longer maximum wait time. Do not assume a fixed completion time.
Try Neural4D for Free

Need assistance? Contact Support.

Read more: Why your next project needs an Image-to-3D API.