moeru-ai/airi · error

Failed to initialize transcription provider

Error message

Failed to initialize transcription provider

What it means

Same guard as the official OpenAI page, but in the openai-compatible transcription settings page: providersStore.getProviderInstance() returned null/undefined for the openai-compatible provider id before any transcription request was made. OpenAI-compatible endpoints need both a stored API key and (usually) a baseUrl; if either is missing or the provider id is unregistered, the factory declines to build an instance and this error is thrown.

Source

Thrown at packages/stage-pages/src/pages/settings/providers/transcription/openai-compatible-audio-transcription.vue:79

})

// Load models
const providerModels = computed(() => {
  return providersStore.getModelsForProvider(providerId)
})

const isLoadingModels = computed(() => {
  return providersStore.isLoadingModels[providerId] || false
})

// 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')

  // Get provider configuration
  const providerConfig = providerStore.getProviderConfig(providerId)

  // Get model from configuration or use the reactive model value
  const modelToUse = providerConfig.model as string | undefined || model.value

  // Validate model - throw error if no valid model configured
  if (!modelToUse || !isValidTranscriptionModel(modelToUse)) {
    throw new Error(`Invalid or missing transcription model. Please configure a valid model in the provider settings.`)
  }

  return await hearingStore.transcription(
    providerId,
    provider,
    modelToUse,
    file,
    'json',

View on GitHub (pinned to 677329427f)

Solutions

  1. Fill in API key and baseUrl for the openai-compatible provider in settings and save before generating.
  2. Confirm the provider is initialized (onMounted calls initializeProvider(providerId)) and that getDefaultProviderConfig(providerId) returns a baseUrl.
  3. Verify providerId matches the registered definition in packages/stage-ui/src/stores/providers.
  4. Inspect earlier console output for a failed getProviderInstance cause (e.g. missing settings record).

Example fix

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

// after
const provider = await providersStore.getProviderInstance<TranscriptionProviderWithExtraOptions<string, any>>(providerId)
if (!provider)
  throw new Error(`Failed to initialize transcription provider "${providerId}". Check that API key and base URL are saved in provider settings.`)
Defensive patterns

Strategy: validation

Validate before calling

const ready = computed(() =>
  !!providers.value[providerId]?.apiKey
  && !!providers.value[providerId]?.baseUrl,
)
if (!ready.value) {
  // disable generation UI until both fields are saved
}

Type guard

function isOpenAICompatibleProviderReady(
  settings: { apiKey?: string, baseUrl?: string } | undefined,
): boolean {
  return !!settings?.apiKey && !!settings?.baseUrl
}

Try / catch

try {
  await handleGenerateTranscription(file)
}
catch (error) {
  if (errorMessageFrom(error).includes('Failed to initialize transcription provider')) {
    // treat as configuration problem: open provider settings, no auto-retry
  }
  throw error
}

Prevention

When it happens

Trigger: Clicking Generate Transcription when the openai-compatible provider has no saved API key, no baseUrl initialized (onMounted only sets the default when missing), or when providerId is not in the providers registry used by getProviderInstance.

Common situations: Using a self-hosted/OpenRouter/Groq-style endpoint but never saving credentials; persisted settings lost after storage reset; switching between stage apps where the provider store was initialized differently; typo'd or renamed providerId after refactoring the providers directory.

Related errors


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