Start an AI tool run
POST/api/tools/:module/runs
Doc 97 §13. Multipart: the photo, the profile slug, YOUR reference for
the end user (the per-person daily limit counts by it), and — when the
profile requires consent — the version of the consent text your app
showed and the person accepted (your attestation). The run is queued
and records surface = api; it passes the same gates, limits, wallet
and metering as any other run. A gate refusal is still 201, with
status = refused and error_code.
Subscribe a webhook endpoint to tool_run.completed / tool_run.failed
to be told when it finishes, or poll GET /api/tools/runs/{run}.
Retries — Idempotency-Key. Send a unique key (a UUID) with each
new run and the SAME key when you retry it. A retry with the same key,
the same server key and the same body returns the original response —
same status, same body, header Idempotent-Replayed: true — and starts
(and charges) nothing new. The same key with a different body is
409 idempotency_key_reused; while the first request is still being
processed, 409 idempotency_key_in_progress (retry after
Retry-After). Keys are scoped per server key and kept for 24 hours.
Only a response that created a run is kept: an error before any run
existed (e.g. 409 consent_required, 422) leaves the key free for
the corrected request.
Request
Responses
- 201
- 400
- 401
- 403
- 404
- 409
- 413
- 422
- 429
The run (pending, or refused by a gate). On an idempotent replay, the original response.
Response Headers
true when this is the stored response of an earlier request with the same Idempotency-Key.
idempotency_key_invalid — the Idempotency-Key header is empty, too long or not printable ASCII.
No token, or an unknown one.
A revoked key, or one without tools:run.
module_unavailable, or unknown_profile (not turned on for the API).
consent_required — with the current consent.text and consent.version;
idempotency_key_reused — this Idempotency-Key was used with a different body;
idempotency_key_in_progress — the first request with this key is still being processed (see Retry-After).
Response Headers
Seconds to wait before retrying (idempotency_key_in_progress only).
image_too_large.
bad_image, unknown_format, or a validation error.
Rate limit exceeded.
Response Headers
Request quota for the current window.
Remaining requests in the current window.
Seconds to wait before retrying.