linshenkx/prompt-optimizer · error · RequestConfigError

Model provider metadata cannot be empty

Error message

Model provider metadata cannot be empty

What it means

Thrown by validateRequest when modelConfig.providerMeta is missing or has no id. The provider metadata id identifies which provider adapter (OpenAI, DashScope, etc.) handles the request, so it is mandatory.

Source

Thrown at packages/core/src/services/image-understanding/service.ts:51

    const providerId = request.modelConfig.providerMeta.id
    const adapter = this.registry.getAdapter(providerId)
    const runtimeRequest = await this.prepareRuntimeRequest(request)

    await adapter.sendImageUnderstandingStream(runtimeRequest, request.modelConfig, callbacks)
  }

  private validateRequest(request: ImageUnderstandingExecutionRequest): void {
    if (!request || typeof request !== 'object') {
      throw new RequestConfigError('Image understanding request cannot be empty')
    }

    const modelConfig = request.modelConfig
    if (!modelConfig) {
      throw new RequestConfigError('Model config cannot be empty')
    }

    if (!modelConfig.providerMeta?.id) {
      throw new RequestConfigError('Model provider metadata cannot be empty')
    }

    if (!modelConfig.modelMeta?.id) {
      throw new RequestConfigError('Model metadata cannot be empty')
    }

    if (!modelConfig.enabled) {
      throw new RequestConfigError('Model is not enabled')
    }
  }

  private async prepareRuntimeRequest(
    request: ImageUnderstandingExecutionRequest
  ): Promise<ImageUnderstandingExecutionRequest> {
    const images = await normalizeImageInputsForLlm(request.images, this.imageInputOptions)
    return {
      ...request,
      images: images ?? request.images,

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Use model configs obtained from ImageModelManager, which guarantees providerMeta.id is set.
  2. If building manually, include providerMeta: { id: 'dashscope', ... } with the provider id.
  3. Validate deserialized configs (zod/schema) before sending them to understand().

Example fix

// before
modelConfig = { modelMeta: { id: 'qwen-vl' }, enabled: true } // no providerMeta

// after
modelConfig = {
  providerMeta: { id: 'dashscope' },
  modelMeta: { id: 'qwen-vl' },
  enabled: true,
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!request.modelConfig.providerMeta?.id) {
  throw new Error('modelConfig.providerMeta.id required')
}

Type guard

const hasProviderMeta = (c: any): c is { providerMeta: { id: string } } =>
  typeof c?.providerMeta?.id === 'string' && c.providerMeta.id.length > 0

Prevention

When it happens

Trigger: Passing a modelConfig where providerMeta was omitted ({ model: {...}, modelMeta: {...} } with no providerMeta) or providerMeta exists but lacks id.

Common situations: Constructing model configs manually instead of retrieving them from the model manager; serializing configs to JSON and losing providerMeta on deserialization; provider records built without an id.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/a0e9a40bd8343f8d. Report an issue: GitHub.