moeru-ai/airi · error

Failed to initialize transcription provider

Error message

Failed to initialize transcription provider

What it means

Thrown by the Comet API transcription playground when `getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)` resolves falsy before calling `hearingStore.transcription`. The store throws distinct errors when the definition or the whole config object is missing, so this branch means the Comet factory built nothing from the saved config — typically a blank/whitespace API key — despite `createProvider` being typed to return a non-nullable instance.

Source

Thrown at packages/stage-pages/src/pages/settings/providers/transcription/comet-api-transcription.vue:65

})

const model = computed({
  get: () => providers.value[providerId]?.model || '',
  set: (value) => {
    if (!providers.value[providerId])
      providers.value[providerId] = {}
    providers.value[providerId].model = value
  },
})

// Check if API key is configured
const apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey)

// Generate transcription
async function handleGenerateTranscription(file: File) {
  const provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)
  if (!provider)
    throw new Error('Failed to initialize transcription provider')

  return await hearingStore.transcription(
    providerId,
    provider,
    model.value,
    file,
    'json',
  )
}

// Use the composable to get validation logic and state
const {
  t,
  router,
  providerMetadata,
  isValidating,
  isValid,
  validationMessage,

View on GitHub (pinned to 677329427f)

Solutions

  1. Save a valid Comet API key in Settings → Providers → Comet API transcription and pass the config validator.
  2. Reload the playground after saving so `getProviderInstance` rebuilds the instance.
  3. Check console for `Error creating provider instance for ...` for the factory's underlying reason.
  4. Confirm the model selector holds a transcription model from the fetched list.
  5. Report persistent falsy results with valid credentials as a factory contract bug.

Example fix

// before
const provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)
if (!provider)
  throw new Error('Failed to initialize transcription provider')

// after
const config = providerStore.getProviderConfig(providerId)
if (!config?.apiKey?.trim())
  throw new Error('Comet API key is empty. Save it in provider settings first.')
const provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)
if (!provider || typeof provider.transcription !== 'function')
  throw new Error('Comet API factory returned no usable instance — check config and console logs')
Defensive patterns

Strategy: validation

Validate before calling

const apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey?.trim())
if (!apiKeyConfigured.value)
  throw new Error('Save a Comet API key before transcribing')

Type guard

function isTranscriptionProvider(v: unknown): v is TranscriptionProviderWithExtraOptions<string, any> {
  return typeof v === 'object' && v !== null && typeof (v as TranscriptionProviderWithExtraOptions<string, any>).transcription === 'function'
}

Try / catch

try { return await hearingStore.transcription(providerId, provider, model.value, file, 'json') }
catch (error) { showError(errorMessageFrom(error)) }

Prevention

When it happens

Trigger: Uploading a file and clicking transcribe before the Comet API key is saved; the key stored as an empty string (config object exists, so the store does not throw); generating while the model computed still holds no usable value and credentials were never completed.

Common situations: Using a Comet API key from a different workspace; key revoked or expired and the field cleared; onboarding skipped with 'force valid'; multiple OpenAI-compatible entries with the key saved in another provider's slot.

Related errors


AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18). Data as JSON: /api/errors/a80a4785d7c5148f. Report an issue: GitHub.