Notice: Black Friday 2026 × Cyber Monday: Get up to 30% extra on top-ups, DeepSeek free to use · View the promotion
Blog

Tutorial

How to Call meshy-7.1/text-to-3d via the HiAPI API: curl and Python Guide

A working integration path from first request to downloaded 3D output

Nov 25, 2026 13 min read
Flat illustration of offset bone-white paper sheets with charcoal edges and one rust-red interleaf, a cover art for a tutorial.
On this page

What the meshy-7.1/text-to-3d endpoint does for your pipeline

Text-to-3D is one of those capabilities that looks like magic in a demo and looks like plumbing in production. The meshy-7.1/text-to-3d model on HiAPI sits on the plumbing side: you send a text prompt describing an object, and the platform returns a generated 3D asset you can download and feed into your own pipeline.

The important architectural detail is that this is not a single request/response call. 3D generation takes time, so the endpoint behaves like a job system. Your integration has three distinct stages, and each one has a different responsibility:

  • Submission — you send the prompt and any generation parameters, and you get back a task identifier.
  • Status tracking — you poll (or otherwise check) that identifier until the job reports completion.
  • Retrieval — once the job is done, you fetch the generated output and store it somewhere you control.

Keeping these three stages separate in your code is the difference between an integration that survives production and one that breaks the first time a generation takes longer than your HTTP timeout. Every section below maps back to one of these stages.

Because the call goes through the HiAPI unified interface, the model is addressed by name (meshy-7.1/text-to-3d) rather than by a provider-specific endpoint. That matters later: if you decide to try a different 3D model, the shape of your request stays the same and the model name becomes a configuration value. You can see the model's current parameter surface on its model page — treat that page as the source of truth for field names and available options rather than hardcoding assumptions from any tutorial, including this one.

What you get back at the end is a downloadable 3D asset. What you do with it — preview in a viewer, convert formats, push to a CDN, attach to a product record — is your pipeline's job, and the retrieval stage is where you hand off.

Before you send your first request

Three things need to be in place before your first call, and none of them are complicated.

An API credential. You need an API key issued from your HiAPI account. This key authenticates every request, both the submission and the status/retrieval calls that follow.

The endpoint base. All calls go to the HiAPI API base URL, with the model identified in the request. Don't hardcode a base URL deep inside a function — put it next to your key in configuration so that both move together.

A way to keep the key out of source code. This is the prerequisite people skip and regret. Minimum viable practice:

  • Store the key in an environment variable (for example HIAPI_API_KEY) and read it at runtime.
  • Add your .env file to .gitignore before you write a single line of code that touches it.
  • In CI and production, inject the key through your platform's secret manager rather than baking it into an image.
  • Never log the key. If you log request headers for debugging, redact the authorization header first.

A small config module pays for itself immediately:

# config.py
import os

HIAPI_BASE_URL = os.environ.get("HIAPI_BASE_URL", "https://api.hiapi.ai")
HIAPI_API_KEY = os.environ["HIAPI_API_KEY"]  # fail fast if missing
MODEL = "meshy-7.1/text-to-3d"

Failing fast on a missing key is deliberate. A KeyError at startup is infinitely easier to diagnose than a 401 six layers deep in a job runner.

One more preparation step: decide up front where generated assets will live. If your first successful generation dumps a file into /tmp and nothing else, you'll be re-doing the retrieval stage properly within a week. A storage bucket or a known asset directory is enough to start.

A working request with curl

With credentials in hand, the submission call is a single POST. The structure looks like this:

curl -X POST "$HIAPI_BASE_URL/v1/generate" \
  -H "Authorization: Bearer $HIAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "meshy-7.1/text-to-3d",
    "input": {
      "prompt": "a low-poly wooden treasure chest with iron bands, game-ready"
    }
  }'

Walking through the fields:

  • model tells the unified endpoint which model to route to. This is the one field you'd change to try a different 3D model later.
  • input.prompt is the text description of the object. Be specific about style, material, and intended use — "game-ready low-poly" and "photorealistic" are very different requests, and the prompt is where you express that.
  • Authorization carries your key as a bearer token.

The exact set of optional generation parameters — and whether your chosen options belong at the top level or inside input — should be confirmed against the model documentation before you build around them. Field names above are the ones you'll be adapting; the shape of the call won't change.

What comes back is not the 3D asset. It's a task descriptor containing an identifier for the job you just created. The response will look roughly like a JSON object with a task or job ID field. Capture that ID — every subsequent step depends on it.

If you're testing from a terminal, pipe the response through a formatter so you can read the ID without squinting:

curl -s -X POST "$HIAPI_BASE_URL/v1/generate" \
  -H "Authorization: Bearer $HIAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"meshy-7.1/text-to-3d","input":{"prompt":"a ceramic coffee mug, studio product style"}}' \
  | python -m json.tool

A 200 response with a task ID means the job is queued or running. It does not mean the model succeeded, and it does not mean the asset is ready — that's the next section.

The same call in Python

Porting to Python should not change any semantics. The same endpoint, the same headers, the same body. What changes is that you gain structure, reuse, and error handling.

A minimal client using requests:

# client.py
import requests

from config import HIAPI_API_KEY, HIAPI_BASE_URL, MODEL


def submit_text_to_3d(prompt: str, **options) -> str:
    """Submit a text-to-3D job. Returns the task ID."""
    payload = {
        "model": MODEL,
        "input": {"prompt": prompt, **options},
    }
    response = requests.post(
        f"{HIAPI_BASE_URL}/v1/generate",
        headers={
            "Authorization": f"Bearer {HIAPI_API_KEY}",
            "Content-Type": "application/json",
        },
        json=payload,
        timeout=30,
    )
    response.raise_for_status()
    data = response.json()
    return data["id"]  # adjust to the task ID field name in the response

A few deliberate choices worth copying:

  • json=payload instead of hand-serializing. requests sets the content type and escapes correctly.
  • timeout=30 on the submission call. Submission is fast; if it takes longer than that, something is wrong — and you don't want a hung thread.
  • raise_for_status() immediately, so failures surface at the call site rather than as a confusing KeyError two lines later.
  • The task ID extraction is isolated in one place. When you confirm the exact response field name against the model docs, you change one line.

The **options passthrough is the part that keeps this client stable over time. As you add generation parameters from the model page, they flow through without touching the function signature.

Now the obvious next question: you have a task ID, but no asset. That's because submission and completion are two different moments in time.

Handling the async task lifecycle

3D generation is not a synchronous API call, and treating it like one is the most common integration bug. A generation job may take anywhere from seconds to minutes depending on the prompt and options. Your code needs to accommodate that without holding an HTTP connection open or blocking a worker indefinitely.

The lifecycle has four states worth modeling explicitly in your code:

  1. Submitted — you have a task ID. The job exists.
  2. Pending/Running — the job is queued or actively generating. Poll and wait.
  3. Succeeded — the job finished; a result is available to fetch.
  4. Failed — the job ended in an error state; retrying the same task won't help, but a new submission might.

Polling loop, the plain version:

import time

def wait_for_task(task_id: str, poll_interval: float = 5.0,
                  max_wait: float = 600.0) -> dict:
    deadline = time.monotonic() + max_wait
    while time.monotonic() < deadline:
        response = requests.get(
            f"{HIAPI_BASE_URL}/v1/tasks/{task_id}",
            headers={"Authorization": f"Bearer {HIAPI_API_KEY}"},
            timeout=30,
        )
        response.raise_for_status()
        task = response.json()
        status = task["status"]

        if status in ("succeeded", "completed"):
            return task
        if status in ("failed", "error"):
            raise RuntimeError(f"3D generation failed: {task}")

        time.sleep(poll_interval)

    raise TimeoutError(f"Task {task_id} not finished after {max_wait}s")

Three design notes on this loop:

Poll at a sane interval. Firing status checks every 100ms is just load with no benefit. Five to ten seconds is a reasonable starting point for 3D jobs; tune based on what you observe.

Always have a deadline. max_wait prevents a worker from spinning forever on a job that is silently stuck. When the timeout hits, treat it as a failure your system can reason about — record the task ID so you can investigate, then decide whether to resubmit.

Match status strings to reality. The status values in the snippet above (succeeded, completed, failed, error) are illustrative. Confirm the actual status vocabulary in the model documentation and map it in one place, so a naming difference doesn't silently fall through your if chain and get treated as "still running."

For production, polling in-process is fine for low volume, but if you're generating hundreds of assets, prefer a durable job system: submission writes the task ID to your database, a background worker polls, and completion triggers the next step. That way a server restart doesn't lose in-flight generations.

Retrieving and storing the generated result

When the status check reports success, the task payload contains a reference to the generated asset — typically a download URL in the result field, sometimes alongside metadata. Treat the URL as short-lived: fetch the file promptly rather than storing the link and hoping it's valid next month.

The retrieval step is a normal HTTP GET followed by a write to storage you control:

def download_result(task: dict, dest_path: str) -> str:
    asset_url = task["result"]["url"]  # confirm field names in docs
    with requests.get(asset_url, stream=True, timeout=120) as r:
        r.raise_for_status()
        with open(dest_path, "wb") as f:
            for chunk in r.iter_content(chunk_size=1 << 20):
                f.write(chunk)
    return dest_path

Why streaming matters: 3D assets can be larger than you expect, and reading the whole response into memory is an easy way to OOM a worker that was doing fine with text APIs. One-megabyte chunks keep memory flat.

Storage practice that will save you later:

  • Write to a temp path, then rename. A partially downloaded file that looks complete is worse than no file. Download to asset.glb.part, then move it into place atomically.
  • Name deterministically. Use your own ID — a database row ID, a content hash, or the task ID — not the remote filename. You'll be able to trace any stored asset back to the job that produced it.
  • Persist the mapping. Store the task ID, prompt, model name, and final asset location together. Six months from now, "which prompt generated this?" should be a query, not an archaeology project.
  • Validate before publishing. Check the file downloaded completely (size matches Content-Length when present) before marking it available to downstream consumers.

Once the asset is in your bucket, the HiAPI portion of the pipeline is done. Everything after is ordinary asset management.

Errors, timeouts, and production hardening

The working path from the previous sections gets you a demo. Production adds failure modes. Here's the checklist to run through before you ship.

Separate your timeouts. Submission, status polling, and asset download have very different expected durations. A single global timeout will either kill legitimate downloads or let stuck submissions hang. Set each call site explicitly, as the code above does.

Distinguish error classes. A 401 means your key is wrong — retrying is pointless, alert instead. A 429 means rate limiting — back off and retry with a delay. A 5xx means a transient platform issue — retry with exponential backoff and jitter. A task that reports failed means the generation itself failed — retrying the same task ID won't help, but resubmitting a (possibly adjusted) prompt might.

Retry the right things. Retries are safe for idempotent status checks and downloads. Be more careful with submission retries: if a submit call times out, the job may have been created anyway. If you retry blindly you can end up with duplicate generations. Consider a request ID or de-duplication key on your side so you can tell.

Cap concurrency. If your service generates assets on demand, a traffic spike can put many jobs in flight at once. Use a queue with a bounded worker pool rather than one thread per request. You'll get predictable throughput and a natural place to apply backoff on 429s.

Log the full lifecycle, not just failures. For each job, log: submission time, task ID, prompt hash (not necessarily the raw prompt, depending on your data policy), poll count, completion time, asset size, and final destination. When a customer says "my model never showed up," these six fields answer the question in seconds.

Make the model name configuration. The MODEL constant in config.py is doing real work. When you want to compare 3D outputs across models or move to a newer release, you change a string rather than rewriting request logic. This is the concrete payoff of going through a unified interface.

Redact secrets in logs and error reports. Exception messages from HTTP libraries will sometimes include headers. Pipe your error reports through a redaction step before they reach your observability tool.

Where to go next

You now have the full loop: submit a prompt, poll the task, download the asset, and store it with enough metadata to trace it later. The next improvements are structural, not net-new APIs.

Wrap the three stages in a small service layer — submit(), wait(), store() — so your application code never constructs an HTTP request directly. Add an abstraction that takes a model name as a parameter, and swapping or A/B testing 3D models becomes a config change. If you're generating at volume, move the polling into a durable worker so restarts don't lose in-flight jobs.

Start with the model page for meshy-7.1/text-to-3d to confirm the current request and response fields, then build the loop above around it.

Related articles

View all articles →

Start building with persistent AI artifacts

Get your API key and call image, video and audio models through one task-based API.

Read the API docs