Product engineering
Depth map API: build or buy, and what the bill actually includes
The model call is one line of code. The product around it is queueing, retries, idempotency, storage, refunds, abuse control, and a contract your customers can rely on.
Start with the request contract
A depth API receives an image and returns a depth representation. The contract should state the accepted format, the maximum size, the output format, the expected latency, the failure modes, and the retention behavior. If any of those is vague, the integration will discover it in production.
DepthCarve's server-to-server endpoint accepts a compressed image data URI up to 1.5 MB, returns a temporary depth-map URL, costs one credit per successful request, and is rate limited per key. The contract is published as OpenAPI so a client can generate a typed wrapper instead of guessing.
Try the workflow
Put this guide against your own image
The tool below is the same workbench described in this article. Generate a free preview, inspect the source checks, and decide whether the image is worth a production file.
Live manufacturing workbench
Upload a photo. Preview the depth. Download your file.
Three free AI previews per day. Source checks, editing, 3D preview, and compatibility exports are free.
Choose a source image to begin.
Queueing is part of the product
A synchronous call that sometimes takes ten seconds and sometimes two minutes is hard to put behind a user interface. A queue with a job id and a poll or callback contract is easier to reason about, but it adds state: queued, processing, succeeded, failed, refunded. Each state needs a timeout and a recovery path.
If the Worker dies between reserving a credit and receiving a provider id, the job can be left in processing forever. The system needs a reconciliation sweep that closes stale rows and refunds the debit. This is not an edge case at scale; it is a Tuesday.
A job contract should expose a stable id, a state, a created time, and a terminal error code. The client should be able to answer three questions without reading logs: is it still running, did it succeed, and if it failed, will the credit come back? A state machine that can only say processing forces support to guess.
Idempotency and credits
A retry should not charge twice. The safest pattern is a client-supplied idempotency key mapped to a server-side job, with one debit per successful job and an automatic refund on confirmed provider failure. The debit and the refund should be separate ledger entries with unique references so a duplicate callback cannot create a second charge.
If the API sells credits, the ledger is the source of truth. Usage counters that are not reconciled with the ledger will drift. The customer will notice before the dashboard does.
Store the idempotency key with the job row and enforce uniqueness in the database, not in application memory. Two workers can process the same retry at the same time; only a unique constraint makes the debit safe. A repeated key should return the original job, not create a second one.
Outputs are temporary unless you pay for storage
Model providers often return signed URLs that expire. A product can either copy the output into its own storage or tell the customer to download it immediately. Copying adds storage cost and retention obligations; not copying adds support load when a link expires.
DepthCarve keeps the provider links temporary and does not store the ZIP. The contract says so, the UI says so, and the rebuild path is free while the link works. If your product needs long retention, budget for object storage and a lifecycle policy rather than pretending the provider URL is permanent.
The real cost per successful request
The model price is only one term. Add the cost of failed calls, retries, idle capacity, storage, egress, support, and the engineering time to keep the queue healthy. A cheap model with a 10% failure rate can be more expensive than a reliable one when the failures are refunded or retried.
Measure cost per successful job, not cost per call. Measure it after refunds and retries. That number is what the price has to cover.
Track four numbers per provider: requests, successes, confirmed failures, and median completion time. A provider that is cheap per call but slow enough to trigger client retries can dominate the bill. Alert on the failure rate and the queue age, not only on the monthly invoice.
Build or buy?
Build when depth is the core differentiator, the volume justifies a dedicated team, and you need control over the model, the data path, or the latency. Buy when depth is a supporting feature and the harder problem is the product around it: accounts, billing, review, and support.
A middle path is to build the product surface and buy the model call. That is what DepthCarve does. The workbench, the review loop, the credit ledger, and the bundle contract are ours; the inference is a provider contract with a fallback and a refund path.
A written exit plan matters too. If the provider changes its price or deprecates the model, can you swap it without changing the customer contract? Keep the model call behind one adapter and store the provider name with each job so a migration is measurable. Record the model version in the job output as well; a silent provider upgrade can change the result even when the contract looks stable.
Before the file moves forward
Final checklist
- The request and response contract is written and versioned.
- The maximum input size and accepted formats are explicit.
- Queue states, timeouts, and recovery paths are defined.
- Retries are idempotent and cannot double-charge.
- Provider failures create a visible refund entry.
- Output retention and expiry are stated to the customer.
- Cost is measured per successful job, not per call.
Straight answers
Questions this workflow raises
How much does a depth map API cost?
The model price is only one part. Add retries, failures, storage, egress, support, and engineering time. DepthCarve charges one credit per successful request; the Production plan includes 1,500 credits per paid cycle and a 60-request-per-minute limit.
Should the API be synchronous or asynchronous?
Use asynchronous jobs with a poll or callback when latency varies. A synchronous call is simpler only when the provider is consistently fast and the client can wait.
What happens when the provider fails?
A confirmed failure should create an idempotent refund for the original debit. A retry must not create a second charge. The failure should be visible in the response and the ledger.
Do you store the uploaded image?
DepthCarve does not store the source image in its database. A compressed copy is sent to the inference provider for the requested job, and provider output links are temporary.