# Error codes (https://docs.cochl.ai/docs/pro/error-codes)






<style href="error-anchor" precedence="default">
  {`
    tr:has(> td > [data-error-anchor]) > td { vertical-align: top; }
    tr:has(> td > [data-error-anchor]:target) > td { background: color-mix(in oklab, var(--color-fd-primary) 10%, transparent); }
    `}
</style>

This page lists the errors you can run into when calling Cochl.Sense Pro — both errors returned immediately when a request is rejected, and errors that show up later inside a completed analysis job. If you're using the official Python library (`cochl`), see [§6](#6-errors-in-the-python-library) for how these appear as exceptions. Every call made with your project keys, the rejected ones included, is listed with its error in the Dashboard’s [Request log](https://docs.cochl.ai/docs/pro/dashboard#4-request-log).

## 1. Two places errors come from [#1-two-places-errors-come-from]

The most important thing to understand about this API's errors is *when* they happen:

| Error kind                           | When                                                        | How it's delivered                                                                                                                                                                                                                                                         |
| ------------------------------------ | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **① Request errors (synchronous)**   | The moment you send the request                             | Auth, option, or file problems. For project-key requests (§3), always a non-200 **HTTP status code**. For speaker recognition (§5), only auth failures use a status code (401) — business-rule violations return **HTTP 200** with the error in the response body instead. |
| **② Analysis errors (asynchronous)** | After the request is accepted, during background processing | `analyze` / `analyze_file` accept the request and immediately return a `job_id`; analysis then runs in the background. Problems in the analysis engines don't come back as HTTP errors — they show up **inside the job result**, per service. (§4)                         |

### Response body shapes [#response-body-shapes]

The shape of the error body depends on which kind of error it is — worth knowing before you write a parser:

| Error type                                                     | HTTP                        | Body shape                                                                                                                                                                                      |
| -------------------------------------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| General error                                                  | 400 / 401 / 402 / 404 / 422 | `{"error": "<message>"}`                                                                                                                                                                        |
| Request validation failure                                     | 422                         | `{"error": "Validation error", "details": [ ... ]}`                                                                                                                                             |
| Result file not ready (`GET /api/v1/jobs/{job_id}/result_url`) | 409                         | `{"error": {"error": "Result not available", "status": "<job status>"}}&#x60; — &#x2A;*`error` is an object here, not a string.**                                                               |
| Internal server error (unhandled)                              | 500                         | `Internal Server Error` — &#x2A;*plain text, not JSON.** Parsing it as `{"error": ...}` will fail. The one `500` that is JSON is [`API key verification failed`](#api-key-verification-failed). |
| Speaker recognition API (`/api/v2`)                            | 200 / 401 / 502             | `{"data": null, "error": "<message>", "debug": "<...>"}`                                                                                                                                        |

## 2. Authentication keys [#2-authentication-keys]

| Key              | Header      | Used for                                                                                    |
| ---------------- | ----------- | ------------------------------------------------------------------------------------------- |
| Project key      | `X-Api-Key` | Audio analysis (`IntegratedApi`) — sound event detection / speech analysis / audio insights |
| Organization key | `X-Org-Key` | Speaker registration & recognition (`SpeakerProfileApi`)                                    |

A project key doesn't expire on its own — issuing a new one invalidates the old one, and a request made with an invalidated key gets `Invalid API key`. Resetting a key on the Dashboard revokes the old one immediately, and the new key works right away.

## 3. Request errors (synchronous — project key) [#3-request-errors-synchronous--project-key]

These are HTTP errors returned by `POST /api/v1/analyze` and `POST /api/v1/analyze_file` at the moment the request is accepted or rejected.

| Situation                                                                                                                                             | HTTP | Response body                                                                                                                                                                                                                    | What to do                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ErrorAnchor id="api-key-required" />Key missing (header absent/empty)                                                                                | 401  | `{"error":"API key required"}`                                                                                                                                                                                                   | Send your project key in the `X-Api-Key` header ([§2](#2-authentication-keys)). Copy it from the Dashboard — [Get your project key](https://docs.cochl.ai/docs/pro/getting-started#2-get-your-project-key).                                                                                                                                                                                                                                                  |
| <ErrorAnchor id="invalid-api-key" />Key invalid (typo, revoked, deleted)                                                                              | 401  | `{"error":"Invalid API key"}`                                                                                                                                                                                                    | Copy the current key from the project’s **Settings** ([Get your project key](https://docs.cochl.ai/docs/pro/getting-started#2-get-your-project-key)). A newly issued key is accepted right away ([§2](#2-authentication-keys)). If it still fails, reset the key or create a new project ([FAQs](https://docs.cochl.ai/docs/pro/faq#faq-4-1)).                                                                                                                                    |
| <ErrorAnchor id="no-services-selected" />No analysis service enabled                                                                                  | 400  | `{"error":"No services selected: turn on sound_event_detection, speech_analysis or audio_insights."}`                                                                                                                            | Enable at least one service — see [Valid service combinations](https://docs.cochl.ai/docs/pro/getting-started#4-valid-service-combinations).                                                                                                                                                                                                                                                                                                                 |
| <ErrorAnchor id="audio-insights-requires-sed-and-speech" />`audio_insights` enabled without both `sound_event_detection` and `speech_analysis`        | —    | Not returned since December 1, 2026 (before that: `400` with `audio_insights requires both speech_analysis and sound_event_detection to be true`)                                                                                | Audio insights can now run on its own — see [Valid service combinations](https://docs.cochl.ai/docs/pro/getting-started#4-valid-service-combinations).                                                                                                                                                                                                                                                                                                       |
| <ErrorAnchor id="options-not-json" />`options` form field isn’t a JSON object (`/analyze_file`)                                                       | 422  | `{"error":"options must be a valid JSON object"}`                                                                                                                                                                                | Send `options` as a JSON-encoded object string, e.g. `{"sound_event_detection": true, ...}`.                                                                                                                                                                                                                                                                                                                                            |
| <ErrorAnchor id="translation-requires-speech-analysis" />`translation` enabled without `speech_analysis`                                              | 400  | `{"error":"translation requires speech_analysis: true"}`                                                                                                                                                                         | —                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| <ErrorAnchor id="sound-event-tags-requires-sed" />`sound_event_tags` sent without `sound_event_detection`                                             | 400  | `{"error":"sound_event_tags requires sound_event_detection: true"}`                                                                                                                                                              | Turn on `sound_event_detection`, or leave `sound_event_tags` out.                                                                                                                                                                                                                                                                                                                                                                       |
| <ErrorAnchor id="unknown-sound-event-tags" />`sound_event_tags` lists a name the model doesn’t know                                                   | 400  | `{"error":"Unknown sound_event_tags: Glass_brake (did you mean Glass_break?). ..."}`                                                                                                                                             | Use the exact, case-sensitive names from [Sound tags](https://docs.cochl.ai/docs/pro/sound-event-detection/sound-tags). An empty list or more than 200 names is a `422`.                                                                                                                                                                                                                                                                                     |
| <ErrorAnchor id="sound-event-thresholds-requires-sed" />`sound_event_thresholds` sent without `sound_event_detection`                                 | 400  | `{"error":"sound_event_thresholds requires sound_event_detection: true"}`                                                                                                                                                        | Turn on `sound_event_detection`, or leave `sound_event_thresholds` out.                                                                                                                                                                                                                                                                                                                                                                 |
| <ErrorAnchor id="unknown-sound-event-thresholds" />`sound_event_thresholds` names a tag the model doesn’t know                                        | 400  | `{"error":"Unknown sound_event_thresholds: Screem (did you mean Scream?). ..."}`                                                                                                                                                 | Use the names from `GET /api/v1/tags`. Values outside 0–1 or an empty object are a `422`.                                                                                                                                                                                                                                                                                                                                               |
| <ErrorAnchor id="custom-thresholds-unavailable" />Custom thresholds can’t be applied right now                                                        | 503  | `{"error":"Custom sound_event_thresholds are unavailable right now. Try again later."}`                                                                                                                                          | Retry later, or send the request without `sound_event_thresholds`.                                                                                                                                                                                                                                                                                                                                                                      |
| <ErrorAnchor id="validation-extra-forbidden" />Undefined option key sent (e.g. a retired field name)                                                  | 422  | `{"error":"Validation error","details":[{"type":"extra_forbidden","loc":["body","options","<field>"], ...}]}`                                                                                                                    | —                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| <ErrorAnchor id="validation-missing-field" />Required field missing (e.g. `samplerate`)                                                               | 422  | `{"error":"Validation error","details":[{"type":"missing","loc":["body","<field>"], ...}]}`                                                                                                                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| <ErrorAnchor id="audio-decode-failure" />Unsupported or corrupted audio file (decode failure, `/analyze_file`)                                        | 400  | `{"error":"empty file"}`, `{"error":"cannot decode .<ext> audio"}`, `{"error":"cannot decode audio (unsupported or corrupted file)"}`, `{"error":"no audio samples found in file"}`, or `{"error":"audio conversion timed out"}` | WAV, FLAC, and OGG are read directly; other formats go through FFmpeg, which is given **120 seconds** per file — a very long or very large file in another format can hit that limit and get `audio conversion timed out`. If the file still can’t be decoded or converted, convert it to MP3, WAV, FLAC, or OGG — [Convert to supported file formats](https://docs.cochl.ai/docs/pro/getting-started#1-convert-to-supported-file-formats-mp3-wav-flac-ogg). |
| <ErrorAnchor id="audio-too-long" />Audio longer than 59 minutes                                                                                       | 400  | `{"error":"Audio is too long: 61:12 (max 59:00). Split the file and try again."}` (with your file’s length)                                                                                                                      | Split the file into parts of 59 minutes or less and send each as its own request.                                                                                                                                                                                                                                                                                                                                                       |
| <ErrorAnchor id="invalid-base64" />Invalid base64 audio data (`/analyze` only)                                                                        | 400  | `{"error":"audio_data is not valid base64"}`, `{"error":"audio_data is empty"}`, or `{"error":"audio_data must be float32 PCM (length must be a multiple of 4 bytes)"}`                                                          | Send raw float32 PCM samples, base64-encoded.                                                                                                                                                                                                                                                                                                                                                                                           |
| <ErrorAnchor id="usage-limit-exceeded" />Trial allowance exceeded: the minutes already used plus this file’s length would go over the 20 free minutes | 402  | `{"error":"exceeded maximum usage limit"}`                                                                                                                                                                                       | Open **Billing** on the Dashboard and click **Add card** to keep going, pay as you go, or contact [support@cochl.ai](mailto:support@cochl.ai) — [FAQs](https://docs.cochl.ai/docs/pro/faq#faq-1-1). A shorter file may still fit in the remaining minutes.                                                                                                                                                                                                   |
| <ErrorAnchor id="not-found" />Path doesn't exist                                                                                                      | 404  | `{"error":"Not Found"}`                                                                                                                                                                                                          | —                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| <ErrorAnchor id="api-key-verification-failed" />Internal error during key verification                                                                | 500  | `{"error":"API key verification failed"}`                                                                                                                                                                                        | —                                                                                                                                                                                                                                                                                                                                                                                                                                       |

<Callout type="info">
  Authentication is always checked first. If your key is missing or invalid, you'll get a 401 even if the request body also has other problems — you won't see a 400 or 422 until the key is valid.
</Callout>

On success, both endpoints return `200` with `{"job_id": "...", "status": "accepted", "created_at": "..."}`. Analysis then continues in the background — see §4.

### Errors when fetching a job [#errors-when-fetching-a-job]

These come from the job endpoints (`GET /api/v1/jobs`, `GET /api/v1/jobs/{job_id}`, and `GET /api/v1/jobs/{job_id}/result_url`), after the same key check as above.

| Situation                                                                                                        | HTTP | Response body                                                             | What to do                                                                          |
| ---------------------------------------------------------------------------------------------------------------- | ---- | ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| <ErrorAnchor id="job-not-found" />Unknown `job_id`, or a job that belongs to another project                     | 404  | `{"error":"Job not found"}`                                               | Use the `job_id` returned by `analyze` / `analyze_file`, with the same project key. |
| <ErrorAnchor id="invalid-date-filter" />`from_date` / `to_date` on `GET /api/v1/jobs` isn’t an ISO 8601 date     | 400  | `{"error":"Invalid from_date (expected ISO 8601 format)"}` (or `to_date`) | Pass dates such as `2026-06-01` or `2026-06-01T09:00:00+00:00`.                     |
| <ErrorAnchor id="result-not-available" />Result file requested before the job has one (still running, or failed) | 409  | `{"error":{"error":"Result not available","status":"processing"}}`        | Wait until the job’s `status` is `completed`. Note that `error` is an object here.  |

Jobs are kept for fast lookup for **24 hours**. After that, `GET /api/v1/jobs/{job_id}` still returns the job’s status and details but no longer includes `result`; fetch the result file through `GET /api/v1/jobs/{job_id}/result_url` instead.

## 4. Service errors inside job results (asynchronous) [#4-service-errors-inside-job-results-asynchronous]

Because `analyze` / `analyze_file` return `200 accepted` as soon as the request is queued, problems during analysis aren't HTTP errors — they appear inside the job result once you fetch it. `GET /api/v1/jobs/{job_id}` returns **HTTP 200** even when a service failed; only that service's entry is marked `status: "error"` (other services that succeeded still return their results — partial success is normal).

```json
GET /api/v1/jobs/{job_id}  ->  HTTP 200
{
  "job_id": "b8cbefce-...",
  "status": "completed",
  "created_at": "...",
  "completed_at": "...",
  "metadata": { "audio": { ... }, "warnings": [] },
  "result": {
    "sound_event_detection": { "status": "error", "error": "This service could not process the audio. Retry, or contact support with the job ID." },
    "speech_analysis":       { "status": "success", "results": [ ... ] },
    "audio_insights":        { "status": "success", "result": { ... } },
    "metadata":              { "audio": { ... }, "warnings": [] }
  }
}
```

The service’s `error` string is the same for every cause — `This service could not process the audio. Retry, or contact support with the job ID.` — so the engine’s internal details don’t reach your app. The one exception is sound event detection with custom thresholds when the model can’t be checked: `Custom sound_event_thresholds could not be applied. Try again later.` Find the likely cause here:

| Cause                                                                                                                                                         | Where it shows up                                                     | `error` string                                                                          |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| <ErrorAnchor id="max-workers-must-be-greater-than-0" />The audio is shorter than one sound event detection window (2 seconds), so there is nothing to analyze | `sound_event_detection`                                               | The common message above — send audio that is **at least 2 seconds** long.              |
| <ErrorAnchor id="asr-engine-api-error" />The analysis engine rejected the job (responded with 3xx or higher)                                                  | `sound_event_detection` and `speech_analysis` (every one you enabled) | The common message above — retry; if it keeps failing, contact support with the job ID. |
| <ErrorAnchor id="asr-engine-call-failed" />The analysis engine couldn’t be reached (timeout after 30 s, network error)                                        | `sound_event_detection` and `speech_analysis` (every one you enabled) | The common message above — retry.                                                       |
| <ErrorAnchor id="audio-insights-error" />The audio insights summary couldn’t be generated                                                                     | `audio_insights`                                                      | The common message above, in `{"status": "error", "error": "..."}`                      |

A whole job can also fail before any service runs (for example, if the uploaded audio can’t be stored). Then the job’s own `status` is `"failed"`, there is no `result`, and the reason is in a top-level `error` field:

```json
GET /api/v1/jobs/{job_id}  ->  HTTP 200
{
  "job_id": "b8cbefce-...",
  "status": "failed",
  "created_at": "...",
  "metadata": { ... },
  "error": "Analysis failed. Retry, or contact support with the job ID."
}
```

On the progress stream this arrives as an `error` event, and `get_completed_result()` returns `None` (§6.1).

**Always check the job’s `status` and each service’s `status` field** — a `completed` job is not the same as a fully successful one. Also check `metadata.warnings`: some option problems don’t fail the request but are reported there instead (for example, a `speech_lang` that wasn’t applied — see [speech analysis](https://docs.cochl.ai/docs/pro/speech-analysis#2-supported-languages)).

## 5. Speaker recognition errors (organization key — `/api/v2`) [#5-speaker-recognition-errors-organization-key--apiv2]

The speaker recognition API (used by `SpeakerProfileApi`) always wraps its response in a `{data, error, debug}` envelope. **Authentication failures return 401** and an unreachable speaker engine returns 502; everything else — business-rule violations — returns **HTTP 200 with an `error` field** (kept for compatibility with the legacy SR server).

| Situation                                                                                                                                   | HTTP | Response body                                                                                                             | What to do                                                                                                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------------------------------------------------------------------------- | ---- | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ErrorAnchor id="x-org-key-required" />Organization key missing (header absent)                                                             | 401  | `{"data":null,"error":"x_org_key required","debug":""}`                                                                   | Send your organization key in the `X-Org-Key` header. Find your organization key (**Account key**) at the bottom of the **Speaker Profiles** page on the Dashboard (under **Account** in the sidebar) ([speaker profile §2.2](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#22-via-the-python-library)). |
| <ErrorAnchor id="organization-not-found" />Organization key invalid (not registered)                                                        | 401  | `{"data":null,"error":"organization not found","debug":""}`                                                               | Find your organization key (**Account key**) at the bottom of the **Speaker Profiles** page on the Dashboard (under **Account** in the sidebar) ([speaker profile §2.2](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#22-via-the-python-library)).                                                       |
| <ErrorAnchor id="speaker-is-invalid" />Speaker name violates naming rules (letters, digits, and underscores only), or is empty              | 200  | `{"data":null,"error":"speaker is invalid. only alphabet, number and underscore are allowed","debug":""}`                 | Use letters, digits, and underscores only — `Anna_Kim`, not `Anna Kim`. Despite the message, letters and digits from any script are accepted ([Limitations](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#6-best-practices--limitations)).                                                               |
| <ErrorAnchor id="file-is-required" />Voice file missing on registration                                                                     | 200  | `{"data":null,"error":"file is required","debug":""}`                                                                     | —                                                                                                                                                                                                                                                                                                           |
| <ErrorAnchor id="an-empty-file" />Empty file uploaded                                                                                       | 200  | `{"data":null,"error":"an empty file","debug":""}`                                                                        | —                                                                                                                                                                                                                                                                                                           |
| <ErrorAnchor id="file-bigger-than-10-mb" />Voice file exceeds 10 MB (blocked client-side by `SpeakerProfileApi` before the request is sent) | —    | `CochlSenseException: one of files is bigger than 10.0 MB` (`add_new_voice`) / `file is bigger than ... MB` (`recognize`) | Keep each voice file under 10 MB ([Limitations](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#6-best-practices--limitations)).                                                                                                                                                                           |
| <ErrorAnchor id="speaker-max-count-exceeded" />Registering a new speaker when the organization already has 50                               | 200  | `{"data":null,"error":"max speakers (50) exceeded for organization","debug":""}`                                          | An organization can register up to 50 speakers ([Limitations](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#6-best-practices--limitations)); profiles are deleted with `remove()` ([§2.2](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#22-via-the-python-library)).                                  |
| <ErrorAnchor id="speaker-max-voices-exceeded" />Adding a voice to a speaker that already has 20                                             | 200  | `{"data":null,"error":"max voices (20) exceeded for speaker '<name>'","debug":""}`                                        | Each speaker can hold up to 20 voice samples ([Limitations](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#6-best-practices--limitations)).                                                                                                                                                               |
| <ErrorAnchor id="enroll-failed" />The voice file couldn’t be processed (for example, it can’t be decoded)                                   | 200  | `{"data":null,"error":"enroll failed","debug":""}`                                                                        | Re-encode the file (WAV is the safest choice) and try again.                                                                                                                                                                                                                                                |
| <ErrorAnchor id="speaker-service-unavailable" />Speaker engine unreachable                                                                  | 502  | `{"data":null,"error":"speaker service unavailable","debug":""}`                                                          | —                                                                                                                                                                                                                                                                                                           |

The server itself doesn’t check the size or duration of a voice file. The 10 MB cap is applied by the Python library before it sends the file, and a take recorded in the Dashboard’s **Add speaker** dialog is at most 30 seconds. Each speaker supports up to **20 voice samples** (5–20 recommended for accuracy), and an organization can register up to **50 speakers** in total.

## 6. Errors in the Python library [#6-errors-in-the-python-library]

Most users call this API through the official Python library rather than raw HTTP. The exceptions it actually raises can differ from the raw API response above, so they're listed separately. This section describes `cochl` 2.0.2 and later (the current version is 2.0.3).

<Callout type="warn">
  `CochlSenseException&#x60; inherits from &#x2A;*`BaseException`, not `Exception`** — a bare `except Exception:` will **not** catch it. You must catch `CochlSenseException` explicitly.
</Callout>

### 6.1 `IntegratedApi` (audio analysis — project key) [#61-integratedapi-audio-analysis--project-key]

When a request fails (any non-2xx response), the library discards the server's detailed message and uses only the **HTTP reason phrase** as the exception message. For example, the server's `Invalid API key` becomes just `Unauthorized`. Every such exception is a `CochlSenseException`. Its `message` attribute holds only the reason phrase; converting the exception to a string (`str(e)`, or printing it) appends a second line, `Please contact support@cochl.ai` — so `str(e)` is `"Unauthorized\nPlease contact support@cochl.ai"` while `e.message` is `"Unauthorized"`.

| Situation                                                                                                                              | API response                       | Library exception                                                                                           | What to do                                                                                                                |
| -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| <ErrorAnchor id="python-unauthorized" />Invalid project key                                                                            | 401 `Invalid API key`              | `CochlSenseException: Unauthorized`                                                                         | See [Invalid API key](#invalid-api-key).                                                                                  |
| <ErrorAnchor id="python-bad-request-file" />Unsupported format or corrupted file                                                       | 400 (detailed message)             | `CochlSenseException: Bad Request`                                                                          | See [decode failure](#audio-decode-failure).                                                                              |
| <ErrorAnchor id="python-bad-request" />No service selected, or an invalid option combination                                           | 400 (detailed message)             | `CochlSenseException: Bad Request`                                                                          | See [Valid service combinations](https://docs.cochl.ai/docs/pro/getting-started#4-valid-service-combinations).                                 |
| <ErrorAnchor id="python-payment-required" />Trial allowance exceeded                                                                   | 402 `exceeded maximum usage limit` | `CochlSenseException: Payment Required`                                                                     | See [usage limit exceeded](#usage-limit-exceeded).                                                                        |
| <ErrorAnchor id="python-too-many-requests" />Too many jobs at once (1 on the trial, 10 on paid plans), or too many open result streams | 429                                | `CochlSenseException: Too Many Requests` from `analyze_file`; the result stream raises urllib’s `HTTPError` | Wait for a running job to finish, then retry. See [Limits](https://docs.cochl.ai/docs/pro/rest-api#6-limits).                                  |
| <ErrorAnchor id="python-internal-server-error" />Server-side error                                                                     | 500                                | `CochlSenseException: Internal Server Error`                                                                | Retry later; if it persists, contact [support@cochl.ai](mailto:support@cochl.ai).                                         |
| <ErrorAnchor id="python-invalid-project-key" />Object created with an empty project key                                                | (before the request is sent)       | `ValueError: invalid project key ""`                                                                        | Pass your project key to `IntegratedApi(...)` — [Get your project key](https://docs.cochl.ai/docs/pro/getting-started#2-get-your-project-key). |
| <ErrorAnchor id="python-service-failed" />An individual analysis service failed                                                        | 200 (inside the result — see §4)   | **No exception raised** — check `result["<service>"]["status"] == "error"` yourself                         | See [§4](#4-service-errors-inside-job-results-asynchronous).                                                              |

<Callout type="warn">
  `get_completed_result(job_id)&#x60; returns **`None`, without raising an exception**, if the job failed (§4) or if it hasn’t finished within **10 minutes** (when the server closes the progress stream). In the second case the job keeps running: call `get_completed_result(job_id)` again, or fetch `GET /api/v1/jobs/{job_id}`, within 24 hours. Always check the return value before using it.
</Callout>

### 6.2 `SpeakerProfileApi` (speaker registration & recognition — organization key) [#62-speakerprofileapi-speaker-registration--recognition--organization-key]

Because speaker recognition's business-rule violations come back as `200 + error`, the library passes the server's actual message straight through. Authentication failures (401) are the one exception — those still collapse to the reason phrase, as with `IntegratedApi`.

| Situation                                                                                                              | Library exception / result                                                                  | What to do                                                                                                                                                                                                                                            |
| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ErrorAnchor id="python-speaker-unauthorized" />Invalid organization key                                               | `CochlSenseException: Unauthorized`                                                         | See [organization not found](#organization-not-found).                                                                                                                                                                                                |
| <ErrorAnchor id="python-speaker-is-invalid" />Speaker name violates naming rules                                       | `CochlSenseException: speaker is invalid. only alphabet, number and underscore are allowed` | See [speaker is invalid](#speaker-is-invalid).                                                                                                                                                                                                        |
| <ErrorAnchor id="python-file-bigger-than-10-mb" />Uploaded file exceeds 10 MB (blocked client-side before the request) | `CochlSenseException: one of files is bigger than 10.0 MB` / `file is bigger than ... MB`   | Keep each voice file under 10 MB ([Limitations](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#6-best-practices--limitations)).                                                                                                                     |
| <ErrorAnchor id="python-invalid-organization-key" />Object created with an empty organization key                      | `ValueError: invalid project key ""`                                                        | Find your organization key (**Account key**) at the bottom of the **Speaker Profiles** page on the Dashboard (under **Account** in the sidebar) ([speaker profile §2.2](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile#22-via-the-python-library)). |

### 6.3 Recommended error-handling pattern [#63-recommended-error-handling-pattern]

```python
from cochl.sense import IntegratedApi, IntegratedApiOptions
from cochl.sense.exception import CochlSenseException
from cochl.sense.http_request import HttpRequestException
import urllib.error

api = IntegratedApi("YOUR_PROJECT_KEY")

try:
    job = api.analyze_file(
        "audio.wav",
        IntegratedApiOptions(
            sound_event_detection=True,
            speech_analysis=False,  # the service flags default to True
            audio_insights=False,
        ),
    )
    result = api.get_completed_result(job["job_id"])

    if result is None:
        # Job failed, or not finished within 10 minutes — not an exception
        print("analysis did not complete")
    else:
        sed = result.get("sound_event_detection", {})
        if sed.get("status") != "success":
            print("SED failed:", sed.get("error"))

except CochlSenseException as e:        # inherits BaseException — must be explicit
    print("API error:", e.message)      # e.g. Unauthorized / Bad Request / Payment Required
except HttpRequestException as e:       # analyze_file: empty file / connection failure
    print("request error:", e.message)
except FileNotFoundError as e:          # missing file
    print("file not found:", e)
except urllib.error.HTTPError as e:     # get_completed_result: 401 invalid key, 404 unknown job_id
    print("stream error:", e.code)
except urllib.error.URLError as e:      # get_completed_result: connection failure
    print("connection error:", e.reason)
```

`get_completed_result()` reads the progress stream with Python’s `urllib`, so its errors are `urllib` exceptions rather than `HttpRequestException`. Keep `HTTPError` before `URLError`: `HTTPError` is a subclass of `URLError`.

Even if you keep a catch-all `except Exception:` as a safety net, put `except CochlSenseException:` **before** it — otherwise API errors go uncaught and the program exits.

<Card title="&#x22;cochlearai/cochl-sense-py&#x22;" description="&#x22;More runnable sample scripts.&#x22;" href="https://github.com/cochlearai/cochl-sense-py" />

### 6.4 Legacy `Client` (`EventDetectionApi`, `cochl` 2.0.1 and earlier) [#64-legacy-client-eventdetectionapi-cochl-201-and-earlier]

<Callout type="info">
  `Client` is the legacy v1.x sound event detection-only client (`api.cochl.ai/sense`, not the Integration API). It was **removed in `cochl` 2.0.2**, so the errors below apply only to code still pinned to 2.0.1 or earlier. Use `IntegratedApi` (§6.1) instead.
</Callout>

| Situation                                                                           | Exception                                                                | Message                                                               |
| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------- |
| <ErrorAnchor id="legacy-invalid-project-key" />Empty/missing project key            | `ValueError`                                                             | `invalid project key ""`                                              |
| <ErrorAnchor id="legacy-file-not-found" />File doesn't exist                        | `FileNotFoundError`                                                      | the file path                                                         |
| <ErrorAnchor id="legacy-invalid-file-format" />Unsupported format (not mp3/wav/ogg) | `ValueError`                                                             | `invalid file format "...", supported formats: ['mp3', 'wav', 'ogg']` |
| <ErrorAnchor id="legacy-api-request-failed" />API request failed                    | `CochlSenseException`                                                    | HTTP reason phrase, or the server's `error` message                   |
| <ErrorAnchor id="legacy-server-side-analysis-error" />Server-side analysis error    | `CochlSenseException`                                                    | the server's `error` message                                          |
| <ErrorAnchor id="legacy-prediction-timed-out" />`predict(timeout=N)` exceeded       | `TimeoutException&#x60; &#x2A;*(also `BaseException`, not `Exception`)** | `Prediction (session_id=...) has timed out "Ns"`                      |

## 7. Rate limits & audio length [#7-rate-limits--audio-length]

There is no request-rate limit, but the number of jobs running at once is capped, and so is the request size:

| Situation                                                                                                                         | HTTP | Response body                                                                                                                     | What to do                                                                                                      |
| --------------------------------------------------------------------------------------------------------------------------------- | ---- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| <ErrorAnchor id="too-many-jobs" />The organization already has its maximum of jobs in progress (1 on the trial, 10 on paid plans) | 429  | `{"error":"Too many jobs in progress for this organization (limit N). Wait for a running job to finish, then retry."}`            | Wait for a job to finish, then retry. Queue your files and send the next one when a job completes.              |
| <ErrorAnchor id="too-many-streams" />The project already has 20 progress streams open                                             | 429  | `{"error":"Too many open result streams for this project (limit 20). Close a stream or poll GET /api/v1/jobs/{job_id} instead."}` | Close streams you no longer read, or poll `GET /api/v1/jobs/{job_id}` ([REST API](https://docs.cochl.ai/docs/pro/rest-api#or-poll)). |
| <ErrorAnchor id="request-body-too-large" />Request body over 1 GiB                                                                | 413  | `{"error":"Request body too large (max 1 GiB)."}`                                                                                 | Compress or split the audio.                                                                                    |

Long files are affected by these limits:

| Limit                                 | Applies to                                                                                 | What happens                                                                                                                                                                                                |
| ------------------------------------- | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **59 minutes maximum**                | Every request: the API, the Python library and the Dashboard                               | A longer file is rejected right away with `400` ([audio too long](#audio-too-long)). Split it and send the parts.                                                                                           |
| **2 seconds minimum**                 | Sound event detection                                                                      | Audio shorter than one 2-second window fails sound event detection with a service error ([§4](#max-workers-must-be-greater-than-0)).                                                                        |
| **120 seconds** for format conversion | Files in formats other than WAV, FLAC, or OGG, converted with FFmpeg when you upload       | The request is rejected right away with `400` `audio conversion timed out` ([decode failure](#audio-decode-failure)).                                                                                       |
| **10 minutes** per progress stream    | The progress stream that `get_completed_result()` and `create_event_stream_request()` read | The stream ends with an `error` event (`Stream timeout`) and `get_completed_result()` returns `None` — but the job keeps running. Call `get_completed_result()` again or fetch `GET /api/v1/jobs/{job_id}`. |
| **24 hours**                          | Job results kept for fast lookup                                                           | After that, `GET /api/v1/jobs/{job_id}` no longer includes `result`; use `GET /api/v1/jobs/{job_id}/result_url` ([Errors when fetching a job](#errors-when-fetching-a-job)).                                |

For very long recordings, splitting them client-side keeps each job well inside the 10-minute stream window; send the parts one after another, or up to your plan’s limit of jobs in progress at once.

## See also [#see-also]

* [Custom sound: Speaker profile](https://docs.cochl.ai/docs/pro/speech-analysis/custom-speaker-profile)—registering and recognizing speakers; see §5 above for its error cases
* [Getting started](https://docs.cochl.ai/docs/pro/getting-started)—setup and your first request
* [Sound event detection](https://docs.cochl.ai/docs/pro/sound-event-detection)—detection details and service options referenced in §3
