janhq/jan · error

Provider configuration is required

Error message

Provider configuration is required

What it means

Thrown by createLanguageModel in ai-model.ts when the `provider` argument is null/undefined. A LanguageModel cannot be constructed without provider configuration (base URL, auth, provider type), so the factory rejects the call up front.

Solutions

  1. Ensure the provider is loaded/resolved before creating the language model (await the providers list)
  2. Verify the model's provider reference points to an existing configured provider
  3. Re-add the missing provider in Settings > Providers
  4. Guard the call site: skip or surface an error when provider is null instead of calling the factory

Example fix

// before
const model = createLanguageModel(modelId, provider, providerObject)
// after
if (!provider) {
  throw new Error(`Provider for model ${modelId} is not configured. Add it in Settings > Providers.`)
}
const model = createLanguageModel(modelId, provider, providerObject)
Defensive patterns

Strategy: validation

Validate before calling

const providers = await getProviders()
const resolved = providers.find((p) => p.provider === model.provider)
if (!resolved) throw new Error(`Provider "${model.provider}" is not configured. Add it in Settings > Providers.`)

Type guard

const isProviderConfigured = (p: ModelProvider | null | undefined): p is ModelProvider =>
  !!p && typeof p.provider === 'string' && p.provider.length > 0

Try / catch

try {
  const model = createLanguageModel(modelId, provider, providerObject)
} catch (e) {
  if (e.message === 'Provider configuration is required') {
    openProviderSettings(modelId)
  }
}

Prevention

When it happens

Trigger: Calling createLanguageModel(modelId, provider, providerObject) with provider === null or undefined — e.g. the provider record was not loaded from settings, was deleted, or the caller passed a lookup result that missed.

Common situations: Referring to a provider that no longer exists in settings; calling the factory before providers are fetched; a typo in the provider lookup key; chat initiated with a model whose provider entry was removed.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17). Data as JSON: /api/errors/bd061e74249f3c8a. Report an issue: GitHub.

Appendix: source

Thrown at web-app/src/lib/ai-model.ts:79

      },
    }
  },
}

/**
 * Creates a LanguageModel instance for the AI SDK based on the provider configuration.
 * This allows using Jan's model providers with the AI SDK's useChat hook.
 *
 * Note: This function is synchronous and does not load the model or construct URLs.
 * URL construction should happen elsewhere after the model is ready.
 */
export function createLanguageModel(
  modelId: string,
  provider?: ModelProvider | null,
  providerObject?: ProviderObject | null
): LanguageModel {
  if (!provider) {
    throw new Error('Provider configuration is required')
  }

  // For llamacpp provider, create a placeholder configuration
  // The actual URL and authentication will be updated later when the model is loaded
  if (provider.provider === 'llamacpp' && providerObject) {
    // Create provider with placeholder connection info
    const openAICompatible = createOpenAICompatible({
      name: 'llamacpp',
      baseURL: 'http://localhost:1337/v1', // Placeholder - will be updated when model loads
      headers: {
        Authorization: 'Bearer placeholder', // Placeholder - will be updated when model loads
        Origin: 'tauri://localhost',
      },
      // Include usage data in streaming responses for token speed calculation
      includeUsage: true,
    })

    // Use languageModel with custom config to include metadata extractor for timings

View on GitHub (pinned to 7205d770c1)