Skip to content

Coding pipeline

POST /v1/code is the hero endpoint. This page covers what it actually does under the hood so you can predict latency, plan around quotas, and choose between sync and async.

For every request, the pipeline runs four stages:

  1. Ingest — verbatims are deduplicated, trimmed, and pre-filtered for empty/junk values. (Heavy noise removal is your responsibility — see NO_DATA for the threshold.)
  2. Codebook — if you didn’t pass an existing codebook, the API generates one from a sample of your responses. You can override this with the codebook field on the request.
  3. Coding — each remaining verbatim is sent to the LLM with the codebook. Each verbatim is one coded response and costs 1 credit.
  4. Review — competing-aspect responses get a needs_review: true flag and a review_reason string. The model can also flag inconsistencies, which you can query through refinement suggestions.

Sync vs async — the 50-response threshold

Section titled “Sync vs async — the 50-response threshold”
Responses in requestHTTP statusWhat you get back
< 50200 OKThe full coded result inline. Typical latency: 5-20s.
≥ 50202 AcceptedA job_id. Poll GET /v1/jobs/{id} or register a webhook.

The threshold is fixed — you can’t force one mode or the other on /v1/code. If you want sync semantics for a larger payload, split it into batches of 49 and reconcile codebooks downstream (or pre-generate the codebook once and pass it on every batch).

Generating a codebook is the slowest part of any first run. For repeated waves, generate it once and pass it on subsequent calls:

POST /v1/code
{
"question": "Why did you choose this brand?",
"codebook": [
{ "code": "Stain removal", "category": "Reason" },
{ "code": "Scent", "category": "Reason" },
{ "code": "Value / pack size", "category": "Reason" }
],
"responses": ["..."]
}

When codebook is provided, the pipeline skips stage 2 entirely. New themes that don’t fit existing codes are surfaced as suggestions rather than added silently — apply them via the refinement endpoints.

queued -> processing -> completed
\-> failed

Jobs are retained for 7 days, then garbage collected.

  • One coded response = one credit.
  • Codebook generation is free.
  • A failed job (status failed before any verbatims were coded) does not charge credits.
  • A job that partially completes charges only for the verbatims that were successfully coded.

See Credits for balance, plans, and what happens when you hit zero.

Stage failures map to specific error codes:

StageLikely error
IngestVALIDATION_ERROR, NO_DATA
CodebookCODEBOOK_GENERATION_FAILED, EMPTY_CODEBOOK
CodingCODING_FAILED, GATEWAY_TIMEOUT
QueueQUEUE_UNAVAILABLE, JOB_ALREADY_RUNNING