How to Check If a Whisper Model Is Available Before Calling a Transcription API
Описание и применение
Внедрение проверки готовности модели Whisper перед отправкой аудио в API транскрипции снижает ненужные попытки, экономит ресурсы и обеспечивает чёткую ошибку при недоступности модели.
Задача
Avoid submitting audio to a transcription API when the selected Whisper model is unavailable, which would waste control‑plane resources and increase costs.
Результат
Implementing a readiness gate reduces unnecessary transcription attempts, lowers costs, and provides a clear failure contract for downstream invoice processing.
Рабочий процесс
- 1. Configure ASR_MODEL_ID and API_BASE_URL via environment variables.
- 2. Call GET /v1/ai/models to retrieve the catalog.
- 3. Find the model with id matching ASR_MODEL_ID and read its "available" boolean.
- 4. Cache the availability value for ~60 s.
- 5. If available is true, proceed to POST /v1/audio/transcriptions; otherwise raise a RuntimeError with "transcription temporarily unavailable".
- 6. Handle HTTP 429 with bounded exponential backoff and honor Retry-After.
- 7. Use idempotency keys for retries to avoid duplicate processing.
Доказательства
Check GET /v1/ai/models first, cache the selected model's available value for about 60 seconds, and call POST /v1/audio/transcriptions only when it is true; the current ASR catalog returns available: false, so show “transcription temporarily unavailable” for the invoice instead.
If the status check receives HTTP 429, use bounded exponential backoff and honor Retry-After; a tight loop turns a service limit into more pressure.
- Дата записи: 2026-10-26T22:11:22.312Z