TencentCloud/TencentDB-Agent-Memory · error

EmbeddingService: model is required for remote provider

Error message

EmbeddingService: model is required for remote provider

What it means

Remote embedding requests must name the embedding model to request from the API. The constructor throws this error when config.model is falsy so that misconfiguration is caught before any network call.

Source

Thrown at MemoryCore/src/core/store/embedding.ts:422

  private readonly apiKey: string;
  private readonly model: string;
  private readonly dims: number;
  private readonly sendDimensions: boolean;
  private readonly providerName: string;
  private readonly proxyUrl?: string;
  private readonly maxInputChars?: number;
  private readonly timeoutMs: number;
  private readonly logger?: Logger;

  constructor(config: OpenAIEmbeddingConfig, logger?: Logger) {
    if (!config.apiKey) {
      throw new Error("EmbeddingService: apiKey is required for remote provider");
    }
    if (!config.baseUrl) {
      throw new Error("EmbeddingService: baseUrl is required for remote provider");
    }
    if (!config.model) {
      throw new Error("EmbeddingService: model is required for remote provider");
    }
    if (!config.dimensions || config.dimensions <= 0) {
      throw new Error("EmbeddingService: dimensions is required for remote provider (must be a positive integer)");
    }
    this.baseUrl = config.baseUrl.replace(/\/+$/, "");
    this.apiKey = config.apiKey;
    this.model = config.model;
    this.dims = config.dimensions;
    this.sendDimensions = config.sendDimensions ?? true;
    this.providerName = config.provider || "openai";
    this.proxyUrl = config.proxyUrl?.trim() || undefined;
    this.maxInputChars = config.maxInputChars && config.maxInputChars > 0 ? config.maxInputChars : undefined;
    this.timeoutMs = config.timeoutMs && config.timeoutMs > 0 ? config.timeoutMs : DEFAULT_API_TIMEOUT_MS;
    this.logger = logger;
  }

  getDimensions(): number {
    return this.dims;

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Set config.model to a valid embedding model (e.g. 'text-embedding-3-small')
  2. Ensure config.dimensions matches the chosen model's output dimensions
  3. Re-read the plugin/config file to confirm the model field is present

Example fix

// before
new EmbeddingService({ apiKey: key, baseUrl: 'https://api.openai.com/v1', dimensions: 1536 })
// after
new EmbeddingService({ apiKey: key, baseUrl: 'https://api.openai.com/v1', model: 'text-embedding-3-small', dimensions: 1536 })
Defensive patterns

Strategy: validation

Validate before calling

if (!config?.model || !String(config.model).trim()) {
  throw new Error('embedding model is required (e.g. text-embedding-3-small)');
}

Type guard

function hasModel(cfg): cfg is OpenAIEmbeddingConfig & { model: string } {
  return typeof cfg?.model === 'string' && cfg.model.trim().length > 0;
}

Try / catch

try {
  svc = new EmbeddingService(config, logger);
} catch (e) {
  if (String(e.message).includes('model is required')) {
    throw new ConfigError('Embedding model not configured');
  }
  throw e;
}

Prevention

When it happens

Trigger: `new EmbeddingService(config)` with apiKey and baseUrl set but config.model undefined, null, or empty string.

Common situations: Typo like 'models' in the config object, config sourced from JSON with the model field missing, or copying a local-provider config (which may not need a model name) into the remote constructor.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/54fa234f77c7a7d2. Report an issue: GitHub.