googleapis/mcp-toolbox · error
error embedding parameters with model %s: %w
Error message
error embedding parameters with model %s: %w
What it means
EmbedParams wraps any error returned by the embedding model's EmbedParameters API call with this message, preserving the root cause via %w. The model itself resolved fine, but the embedding request failed — the real cause (network, auth, provider error) is in the wrapped error after this prefix.
Source
Thrown at internal/util/parameters/parameters.go:220
})
}
// Batch embedding request sent to each model
for modelName, params := range parametersToEmbed {
model, ok := pMgr.GetEmbeddingModel(modelName)
if !ok {
return nil, fmt.Errorf("embedding model does not exist: %s", modelName)
}
// Extract only the string values for the API call
stringBatch := make([]string, len(params))
for i, paramStr := range params {
stringBatch[i] = paramStr.OriginalValue
}
embeddings, err := model.EmbedParameters(ctx, stringBatch)
if err != nil {
return nil, fmt.Errorf("error embedding parameters with model %s: %w", modelName, err)
}
if len(embeddings) != len(stringBatch) {
return nil, fmt.Errorf("model %s returned %d embeddings for %d inputs", modelName, len(embeddings), len(stringBatch))
}
for i, rawVector := range embeddings {
item := params[i]
// Call vector formatter
var finalValue any = rawVector
if formatter == nil {
paramValues[item.Index].Value = finalValue
continue
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Unwrap the error (errors.Unwrap / %w chain) and read the underlying provider message; fix that first.
- Verify provider credentials (API key env vars, Application Default Credentials) are present and valid.
- Test network connectivity to the embedding provider endpoint from the runtime environment.
- Reduce batch size and add exponential backoff for rate-limit (429) responses; check quotas.
- Confirm the model kind/name in config is one the provider actually supports.
Example fix
// before: opaque wrapper only
if err != nil { return err }
// after: surface the root cause
embeddings, err := model.EmbedParameters(ctx, batch)
if err != nil {
return fmt.Errorf("embedding failed: %w", err) // inspect wrapped cause
} Defensive patterns
Strategy: retry
Validate before calling
// pre-flight at startup
if _, err := model.EmbedParameters(ctx, []string{"ping"}); err != nil {
log.Fatalf("embedding provider unavailable: %v", err)
} Try / catch
embeddings, err := model.EmbedParameters(ctx, batch)
if err != nil {
if isRetryable(err) { // 429/5xx
time.Sleep(backoff); return retry(batch)
}
return fmt.Errorf("embedding unavailable: %w", err)
} Prevention
- Provide provider credentials via env vars/secret manager and rotate them before expiry.
- Pre-flight a tiny embedding call at startup to fail fast on auth or network issues.
- Add retry with exponential backoff for rate limits; monitor quotas.
- Verify egress/firewall rules allow the runtime to reach the provider endpoint.
When it happens
Trigger: model.EmbedParameters(ctx, stringBatch) returns a non-nil error during a batch embedding call: network failure to the provider, missing/invalid API credentials, quota or rate-limit rejection, or a provider 4xx/5xx response.
Common situations: Expired or absent provider API keys (env vars / ADC not set in the deployment environment); blocked egress in VPC or Cloud Run; hitting provider rate limits with large parameter batches; misconfigured model endpoint or project settings.
Related errors
- failed to verify allowedDataset '%s' in project '%s': %w
- error fetching connections: %w
- error fetching LookML models: %w
- error embedding parameters: %w
- toolbox failed to start listener: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/9096eac8dfa02f75.
Report an issue: GitHub.