Guides

Errors

The API uses standard HTTP status codes. Error bodies are JSON.

Status codes

StatusBodyMeaningRetry?
400{"detail": "{\"detail\":\"Invalid WAV file format\"}"} (double-encoded)The assessment service can’t use the request: language other than us/uk, empty transcript, invalid base64, audio that isn’t a readable WAV, empty, or shorter than 0.1 seconds.No. Fix the request.
401{"detail": "Missing or invalid Authorization header"} or {"detail": "Invalid token: …"}No bearer token, or the token is malformed, not issued by Taktik, or expired.No. Fix the header or ask us for a new token.
422{"detail": [ … ]}The JSON body is invalid: a required field is missing or has the wrong type.No. Fix the request; detail[].loc points to the field.
429{"error": "Rate limit exceeded: 10 per 1 minute"}More than 10 requests in the current minute from your IP address.Yes, after waiting for the next minute.
500{"detail": "Gateway error forwarding to pronunciation-service: ReadTimeout(…)"}Usually a recording that took longer than 30 seconds to assess: the gateway stops waiting and answers 500. Other unexpected errors also land here (from the assessment service they are double-encoded).Once or twice, with a delay. For timeouts, send a shorter recording. If it persists, contact us.
503{"detail": "Pronunciation service at capacity, please retry"} or {"detail": "{\"detail\":\"Model is still loading, please retry\"}"}The assessment service stayed busy even after our gateway retried for you, or the model is still loading on an instance that has just started.Yes, with exponential backoff.
504{"detail": "{\"detail\":\"Model inference timed out after 30.0s\"}"} (double-encoded)Model inference took longer than 30 seconds. Rare: the gateway’s own 30-second timeout usually fires first and you get 500 instead.Not unchanged. Send a shorter recording.

Error body shapes

Most errors have a string detail (double-encoded when it comes from the assessment service, see below). Two exceptions:

  • 422 returns a list of problems in detail, one per invalid field:
422 Unprocessable Entity
{
  "detail": [
    {
      "type": "missing",
      "loc": ["body", "transcript"],
      "msg": "Field required",
      "input": { "audio_base64": "UklGRi..." }
    }
  ]
}
  • 429 uses an error field instead of detail.

Errors from the assessment service are double-encoded

When the assessment service itself rejects or fails a request (400, 503 while the model loads, 504, and some 500s), the gateway passes its status code through and puts the service’s whole JSON error body, as text, in detail. So detail is a string that contains JSON:

400 Bad Request
{
  "detail": "{\"detail\":\"Invalid WAV file format\"}"
}

Parse detail a second time to read the message, and fall back to the plain string when it isn’t JSON. This handles every error shape the API returns today:

JavaScript
// Errors raised by the assessment service wrap its JSON body in a string.
async function errorMessage (response) {
  const body = await response.json().catch(() => null)
  if (!body) return `HTTP ${response.status}`
  if (body.error) return body.error                         // 429
  if (typeof body.detail !== 'string') return JSON.stringify(body.detail) // 422
  try {
    const inner = JSON.parse(body.detail)                   // double-encoded
    if (inner && typeof inner.detail === 'string') return inner.detail
  } catch {}
  return body.detail                                        // plain string
}

This is how the API behaves today. If the format changes, it will be a separate, versioned change, so code written like the example above keeps working.

Other status codes from the assessment service

Treat any other 4xx as a problem with the request and don’t retry it unchanged.

Retry strategy

  • Retry only 429, 503 and, sparingly, 500. Don’t retry 400, 401 or 422 unchanged.
  • Use exponential backoff with jitter, for example 1 s, 2 s, 4 s, and give up after a few attempts.
  • For 503, note that the gateway has already retried for a few seconds before answering.
  • For 429, see Rate limits.