Skip to content

Developer API ​

Generate and refine CAD designs from text, reference images and supported CAD/3D files in your own applications. The API runs in the background using the same agent, credit balance and export serializers as the app.

API keys and credits ​

Explore the API overview from the site's API navigation link. Open API settings through Get an API key, the documentation's API tab, or Avatar → Developer API inside the app.

Sign in, open your avatar menu and choose Developer API, or visit Developer settings. Name your integration and select Create API key. Copy the secret immediately: it is shown only once. Revoke keys on the same page: select Revoke, then confirm Revoke API key. Revocation blocks new requests; already accepted work can finish. A revoked key cannot be restored.

If you are signed out, the workspace offers Sign in with Google and returns you to /developer after authentication. The same prompt appears if a key-management request reports an expired session, even when the app still shows cached account data. Temporary loading failures offer Try again or Refresh keys.

The account owner must explicitly accept the current Terms of Service in the web app before managing keys or using an existing key. If the API returns 403 terms_acceptance_required, sign in at the app, review the linked Terms, select the I agree checkbox and choose Accept and continue. Acceptance is free and is shared across your account's devices, API keys and plugin access.

The workspace includes a named-key form, creation/last-use dates, a one-time secret panel and copyable Create / Generate / Refine / Export examples. Set PROMPT2CAD_API_KEY, then set PROJECT_ID and GENERATION_ID from the earlier API responses before running the relevant examples. Creating keys and copying examples do not generate CAD or spend credits.

Store the secret on your server. Send Authorization: Bearer p2c_api_… on every request.

Base URL: https://prompt2cad.com/api/v1 · OpenAPI specification

The workspace shows the base URL for the current environment. Preview keys belong to preview, not production; private preview clients also need the preview access cookie. The preview password is an access gate, not a substitute for Google sign-in.

During beta rollout, generation_unavailable (503) means new server-side work is temporarily disabled. That response does not start a paid generation; existing usage and status reads remain available.

Generation and paid auxiliary tools use your existing credits, with the same trial allowance and model eligibility as the app. API CAD downloads are available during the trial without a top-up. When credits run out, top up in the app to generate more. Previously generated API artifacts remain downloadable until they expire. There is no extra customer credit charge for exporting or uploading reference images and CAD/3D files in this release. Web-app downloads retain their existing purchase requirements.

Workflow ​

  1. POST /projects with { "name": "Motor bracket" }.
  2. Optionally upload images using POST /files or CAD/3D sources using POST /cad-files.
  3. POST /projects/{projectId}/generations with prompt and optional imageFileIds and cadFileIds.
  4. Poll GET /projects/{projectId}/generations/{generationId} every 5 seconds.
  5. When completed, POST /projects/{projectId}/exports with generationId and formats.
  6. Poll GET /projects/{projectId}/exports/{exportId} and download completed artifacts using their downloadUrl and your API key.
  7. Refine by submitting another prompt to the same project. The agent retains its conversation and CAD model.

Projects are server-owned. Keep their IDs in your integration. This release supports API-created projects; it does not import existing web-app projects or provide an embedded editor.

Retries ​

Creating a project, submitting a generation, requesting an export and resuming a paused generation require an Idempotency-Key header: 1–128 letters, numbers, dots, underscores, colons or hyphens. Reuse the key when retrying the same operation. Keys are scoped to your account and endpoint; different input with the same key returns 409. Use a new key for a new refinement or export.

New generation/export requests return 202 Accepted; identical retries may return 200. Acceptance means work is queued, not that a valid model has already been produced.

Choose the AI model ​

Set model on each generation request, including refinements:

  • Omit it or use "default" for the configured default CAD agent, currently DeepSeek V4.1 Flash 1017 for all countries and account balances.
  • Use "deepseek/deepseek-v4.1-flash-1017" to select that model explicitly.

The previous "deepseek/deepseek-v4.1-flash" ID remains accepted as an alias for 1017, including when resuming a generation saved with that ID.

json
{
  "prompt": "Increase the bracket width to 120 mm and keep the holes unchanged.",
  "model": "deepseek/deepseek-v4.1-flash-1017"
}

Current customer rates, in USD per million tokens:

ModelInputCached inputOutput, including reasoning
DeepSeek V4.1 Flash 1017 (default)$1.20$0.024$4.80

Billing uses actual token usage and the same account credits as the app. Reported cached input uses the dedicated cached rate only for provider-reported cache hits; successful non-zero-token calls round up to whole credits, with a minimum one-credit charge. A cheaper token rate does not guarantee a fixed price per design: token counts, iterations and paid auxiliary tools also affect the total.

The choice applies to that generation and its continuations/resumes. It does not set a project-wide preference: omitting model on the next refinement uses the current default. Independent review subagents always use DeepSeek V4.1 Flash, including when the main generation uses another model. Shared implementation children retain the parent's selected model. You can switch models while retaining the project's conversation and geometry. The generation response's model reports the selected option. Unsupported IDs return 400; changing the model with the same idempotency key returns 409. This API choice is available without enabling the app's experimental model-picker feature flag.

Images ​

Upload raw JPEG, PNG or WebP bytes to POST /files with the matching Content-Type. The response contains id, mimeType and bytes. Include up to four uploaded IDs:

json
{
  "prompt": "Model this bracket. The base is 100 mm wide.",
  "imageFileIds": ["YOUR-UPLOADED-FILE-ID"],
  "unitSystem": "metric"
}

Limits: 20 MiB and 40 megapixels per upload; 200 MB of normalized reference storage per account. Images are normalized to JPEG with a longest side of 768 pixels, belong to the uploading account, and can be reused for refinement. Include dimensions in your prompt: a reference image alone does not establish accurate scale.

CAD and 3D files ​

Upload raw file bytes to POST /cad-files?fileName=plate.stl&units=mm, with Content-Type: application/octet-stream. The filename is required; units is an optional source-unit override (mm, cm, m, in, ft). The response contains an id, byte counts, units, part counts, bounds and skipped entities. Check these source facts before generating, especially when the source has no reliable scale.

bash
curl 'https://prompt2cad.com/api/v1/cad-files?fileName=plate.stl&units=mm' \
  -H "Authorization: Bearer $PROMPT2CAD_API_KEY" \
  -H 'Content-Type: application/octet-stream' \
  --data-binary @plate.stl

Include up to four unique CAD upload IDs in a generation or refinement:

json
{
  "prompt": "Use the attached plate as the base and add two 6 mm mounting holes.",
  "cadFileIds": ["YOUR-UPLOADED-CAD-FILE-ID"],
  "unitSystem": "metric"
}

Supported inputs: DWG, DXF, SKP, OBJ, STL, GLB and glTF. GLB/glTF must be self-contained, with embedded buffers and images; external companion files and URLs are rejected. OBJ companion material/texture files are not uploaded by this endpoint. STEP, IGES and native CAD project formats are not supported inputs. DWG/DXF entity support follows the app importer; DWG ACIS solids are not decoded.

Uploads are references until the agent explicitly inserts them. Ask it to use the source when you want its geometry included, or to inspect it when you only need dimensions or layout guidance. Imported meshes remain meshes; attaching a file does not automatically reconstruct a parametric feature history. Sources remain available in the project for later refinements without resending their IDs. Each model file can contain one imported source; another source can be used in a separate model file.

Limits: 10 MiB source, 8 MiB normalized geometry per upload, 16 MiB retained CAD attachments per project, and 200 MiB source plus normalized CAD storage per account. Complex files may exceed the geometry limit even when the original is small. Upload IDs belong to the uploading account and can be reused across its API projects. CAD uploads do not require an idempotency key; retrying an upload creates another ID.

Autonomous and interactive generation ​

executionMode defaults to autonomous: clarification questions accept the agent’s suggested defaults and validated room plans are automatically approved. Selected defaults appear in the generation response’s assumptions array.

Set executionMode: "interactive" for explicit questions and room-plan approval. When status is awaiting_input, read questions and planReviews:

  • POST /projects/{projectId}/generations/{generationId}/answers with { "toolCallId": "…", "answers": [{ "id": "width", "value": 1.2 }] }. Answer every question in the pending call. Internal length values are meters.
  • POST /projects/{projectId}/generations/{generationId}/approval with { "toolCallId": "…", "approved": true }, or reject with approved: false and feedback.

Generation states: accepted, running, awaiting_input, paused, completed, failed, cancelled. usage exposes billed credits and tool-call count. New generations include settled compaction summaries in reported credits, as well as main-agent, child and auxiliary usage. These are existing credit charges, not an extra fee. Historical usage is not retroactively reconstructed, and already-running work can still settle after cancellation.

If a saved model request is repeatedly interrupted, automatic regeneration stops and the generation becomes failed with an explanatory error; the saved CAD state is retained. Submit another prompt to the same project with a new idempotency key to continue it. Retrying an already-failed generation's original submission key returns that same result, rather than starting new paid work.

Repeated server memory-limit resets also stop automatic recovery. The generation then reports status: "failed" with error.code: "generation_memory_limit"; the saved CAD state and paid-request records are retained. This resource failure does not mean the account needs more credits. Poll the same generation to read the terminal state; a transient HTTP 503 during a reset is not permission to submit a replacement generation automatically. A deliberate new prompt uses normal model credits, and already in-flight usage may still settle.

Independent review and delegated work ​

API generations can delegate work to isolated subagents. The agent defaults to an independent final review for new designs and substantive geometry or functional changes. An independent reviewer receives the current request, the target file's approved plan and explicitly selected reference images, with read-only geometry and screenshot tools. Shared implementation children work in separate copies; their changes reach the main model only after explicit, validated integration by the parent agent. Children cannot start more children.

Poll the same generation endpoint and inspect its subagents array. Each entry includes context (independent or shared), status, fileId, durationMs, output, any error, and child usage. Child states are running, completed, failed, timed_out or killed. For independent reviews, reviewSourceCodeHash and reviewHash bind a conclusive structured report to successful inspection evidence, and matchesCurrentModel tells you whether the reviewed model and plan still match the current file. output is a human-readable explanation; do not parse it to classify the review. An empty array means no child was started.

For collection QA, require a completed independent review, matching current geometry, and reviewReport.verdict === "no_findings" with an empty findings array. New independent reviewers submit the following versioned JSON object:

json
{
  "version": 1,
  "fileId": "main",
  "verdict": "no_findings",
  "findings": [],
  "summary": "No material defects in the inspected state.",
  "checks": ["Inspected overview screenshots and measured parameter endpoints."]
}

verdict is classified by the reviewer: no_findings, findings, or inconclusive. A findings report contains one to three objects with severity (P0 or P1), issue, evidence and recommendedAction. The other verdicts require an empty findings array. summary and checks are explanations, not machine-decision fields. An inconclusive report means the necessary inspection could not be completed; it receives no inspection hashes and is not approval. Changing the model or plan after submission invalidates the report.

Older receipts may have only output. Their prose is not automatically converted to a verdict: obtain a structured review or have an LLM interpret that historical report in your integration. There is no regex/keyword fallback. Submission of a review report uses normal agent tool calls and model credits, with no separate fee.

A generation's completed status means the agent turn ended; it is not independent review approval or a manufacturing certification. Trivial changes may not need a new review.

Independent reviews always use DeepSeek V4.1 Flash; their model field reports deepseek/deepseek-v4.1-flash-1017. Shared implementation children use the generation's selected model. All child calls use existing account credits at the actual model's rates. Top-level usage includes child spend and tool calls; per-child usage is a breakdown, not an additional debit. Credit and elapsed-time segment budgets apply to parent and children together; tool-call budgets are independent for each agent. Up to four children can run at once, with a ten-minute default child timeout. Interrupted server execution replays frozen child requests and saved results. Pausing, cancelling or ending the parent stops unfinished children; this may leave an incomplete review. Already in-flight work may still settle and be billed. There is no separate API review-skip control.

API segments allow 200 tool calls for the parent and 200 for each child. Child tool calls do not consume the parent's or another child's allowance. A child that reaches its limit stops with an error available to the parent; the parent can continue within its own allowance. Reaching the parent's limit requires confirmation to continue. Interactive UI chat uses 50 calls per agent. Usage totals still include all child calls and normal credit charges apply. The API's other segment limits are 5,000 billed credits or 30 minutes. An in-flight model request may settle beyond those thresholds. Autonomous mode does not authorize another segment automatically. Explicitly POST .../{generationId}/resume with a new idempotency key to continue. POST .../{generationId}/cancel requests a cooperative stop; already-running work may finish and its usage may be billed. Resuming the same generation starts a fresh segment budget; it does not erase previous usage or grant free model calls. The selected model's normal credit rates and account balance checks still apply.

Exports ​

Formats: step, dxf, skp, glb, dae, obj, stl, 3mf, png. OBJ is a ZIP containing OBJ and MTL companions. PNG is a perspective viewport preview, not an AI-generated photorealistic render. Format limitations match the app’s exports.

json
{
  "generationId": "YOUR-COMPLETED-GENERATION-ID",
  "fileId": "main",
  "formats": ["step", "glb", "png"]
}

Use a completed generation and a file ID from its files array (main is the default). Exports capture that generation’s immutable model snapshot and revision; later refinements cannot change an export already requested. Check each artifact’s status: an export may complete with some formats failed. Maximum artifact size is 40 MB.

Artifacts expire 7 days after export creation (expiresAt is Unix milliseconds). Use a new idempotency key to request another export after expiry. DELETE /projects/{id} makes the project and its artifacts inaccessible and cleans up associated assets.

Limits and errors ​

Account-wide limits across all keys: 120 requests/minute, 10 image uploads/minute, 10 CAD uploads/minute, 3 active generations, 3 active exports, one generation/project, 20 active keys. JSON bodies are limited to 200 KB.

Errors contain error.code, error.message, requestId. Responses include X-Request-ID; 429 includes Retry-After. Retry network errors and 503 using the same idempotency key. Resolve invalid input or conflicts before changing requests. Polling never creates a paid generation. GET /usage returns credits and limits. GET /projects/{id} returns the latest 20 lightweight summaries (ID, prompt, status, revision, timestamps and pause reason). Read a generation individually for usage, questions, files and output; older generation IDs remain readable individually.

JavaScript example ​

The official SDK repository includes a JavaScript client with TypeScript declarations, Python examples and coding-agent integration instructions. For an HTTP client workflow, fork the collection in the public Postman workspace. It covers generation, CAD modification, refinement, image references and exports; run requests individually and poll to completion between steps. The published Postman reference is readable without signing in.

Node 22+, with PROMPT2CAD_API_KEY set. Set RUN_ID to reuse operation identities after restarting. A paused/failed operation stops the example instead of authorizing more expenditure automatically.

js
import { randomUUID } from "node:crypto";
import { writeFile } from "node:fs/promises";
const origin = "https://prompt2cad.com";
const run = process.env.RUN_ID || randomUUID();
const headers = { Authorization: `Bearer ${process.env.PROMPT2CAD_API_KEY}` };
async function api(path, body, operation) {
  const response = await fetch(`${origin}/api/v1${path}`, {
    method: body === undefined ? "GET" : "POST",
    headers: { ...headers, "Content-Type": "application/json",
      ...(operation ? { "Idempotency-Key": `${run}:${operation}` } : {}) },
    body: body === undefined ? undefined : JSON.stringify(body),
  });
  const result = await response.json();
  if (!response.ok) throw new Error(JSON.stringify(result));
  return result;
}
async function poll(path) {
  for (let i = 0; i < 420; i++) {
    const result = await api(path);
    if (result.status === "completed") return result;
    if (!["accepted", "running"].includes(result.status)) throw new Error(JSON.stringify(result));
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
  throw new Error("Polling timed out; retain the operation ID and reconnect");
}
const project = await api("/projects", { name: "Bracket" }, "project");
const base = `/projects/${project.id}`;
const generation = await api(`${base}/generations`, {
  prompt: "Create an L bracket, 100 mm wide, with 6 mm walls and two mounting holes.",
}, "generate");
console.log({ run, projectId: project.id, generationId: generation.id });
await poll(`${base}/generations/${generation.id}`);
const exported = await api(`${base}/exports`, {
  generationId: generation.id, formats: ["step", "png"],
}, "export");
const result = await poll(`${base}/exports/${exported.id}`);
for (const artifact of result.artifacts) {
  if (artifact.status !== "completed") { console.error(artifact); continue; }
  const response = await fetch(`${origin}${artifact.downloadUrl}`, { headers });
  if (!response.ok) throw new Error(await response.text());
  await writeFile(artifact.filename, Buffer.from(await response.arrayBuffer()));
}

Python example ​

Python 3, using only its standard library:

python
import json, os, time, uuid
from pathlib import Path
from urllib.request import Request, urlopen
origin = "https://prompt2cad.com"
run = os.environ.get("RUN_ID", str(uuid.uuid4()))
headers = {"Authorization": "Bearer " + os.environ["PROMPT2CAD_API_KEY"]}
def api(path, body=None, operation=None):
    h = dict(headers, **{"Content-Type": "application/json"})
    if operation:
        h["Idempotency-Key"] = run + ":" + operation
    data = None if body is None else json.dumps(body).encode()
    with urlopen(Request(origin + "/api/v1" + path, data=data, headers=h), timeout=60) as response:
        return json.load(response)
def poll(path):
    for _ in range(420):
        result = api(path)
        if result["status"] == "completed":
            return result
        if result["status"] not in ("accepted", "running"):
            raise RuntimeError(result)
        time.sleep(5)
    raise TimeoutError("Retain the operation ID and reconnect")
project = api("/projects", {"name": "Bracket"}, "project")
base = "/projects/" + project["id"]
generation = api(base + "/generations", {
    "prompt": "Create an L bracket, 100 mm wide, with 6 mm walls and two mounting holes."
}, "generate")
print({"run": run, "projectId": project["id"], "generationId": generation["id"]})
poll(base + "/generations/" + generation["id"])
exported = api(base + "/exports", {"generationId": generation["id"], "formats": ["step", "png"]}, "export")
result = poll(base + "/exports/" + exported["id"])
for artifact in result["artifacts"]:
    if artifact["status"] != "completed":
        print(artifact)
        continue
    with urlopen(Request(origin + artifact["downloadUrl"], headers=headers), timeout=60) as response:
        Path(artifact["filename"]).write_bytes(response.read())

Next: SketchUp integration · Export formats

Docs for Prompt2CAD — derived from the source code at the commit that built them.