spring-projects/spring-ai · warning
No embeddings returned for request: + request
Error message
No embeddings returned for request: + request
What it means
Warning logged by MistralAiEmbeddingModel.call() when the embeddings HTTP response body is null — no EmbeddingList was returned by mistralAiApi.embeddings(). The model returns an empty EmbeddingResponse (no embeddings, no usage metadata) instead of throwing.
Source
Thrown at models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiEmbeddingModel.java:131
var apiRequest = createRequest(embeddingRequest);
var observationContext = EmbeddingModelObservationContext.builder()
.embeddingRequest(embeddingRequest)
.provider(MistralAiApi.PROVIDER_NAME)
.build();
return EmbeddingModelObservationDocumentation.EMBEDDING_MODEL_OPERATION
.observation(this.observationConvention, DEFAULT_OBSERVATION_CONVENTION, () -> observationContext,
this.observationRegistry)
.observe(() -> {
var embeddingResponseEntity = RetryUtils.execute(this.retryTemplate,
() -> this.mistralAiApi.embeddings(apiRequest));
MistralAiApi.EmbeddingList<MistralAiApi.Embedding> apiEmbeddingResponse = embeddingResponseEntity
.getBody();
if (apiEmbeddingResponse == null) {
if (logger.isWarnEnabled()) {
logger.warn("No embeddings returned for request: " + request);
}
return new EmbeddingResponse(List.of());
}
var metadata = new EmbeddingResponseMetadata(apiEmbeddingResponse.model(),
getDefaultUsage(apiEmbeddingResponse.usage()));
var embeddings = apiEmbeddingResponse.data()
.stream()
.map(e -> new Embedding(e.embedding(), e.index()))
.toList();
var embeddingResponse = new EmbeddingResponse(embeddings, metadata);
observationContext.setResponse(embeddingResponse);
return embeddingResponse;
});View on GitHub (pinned to 98a7beda4f)
Solutions
- Verify the configured embedding model name is valid for your Mistral account.
- Check API key validity and rate-limit/quota status.
- Inspect raw HTTP traffic with a client interceptor to confirm what the endpoint returned.
- Handle empty EmbeddingResponse.getResults() defensively before building vectors.
Example fix
// before
EmbeddingResponse er = embeddingModel.call(new EmbeddingRequest(texts, opts));
float[] v = er.getResults().get(0).getOutput();
// after
if (er.getResults().isEmpty()) throw new IllegalStateException("No embeddings returned for " + texts.size() + " inputs"); Defensive patterns
Strategy: validation
Validate before calling
Assert.hasText(embeddingModelName, "Mistral embedding model must be configured"); // e.g. 'mistral-embed'
Type guard
static boolean hasEmbeddings(EmbeddingResponse r) { return r != null && r.getResults() != null && !r.getResults().isEmpty(); } Try / catch
EmbeddingResponse er = embeddingModel.call(req);
if (!hasEmbeddings(er)) throw new IllegalStateException("Mistral returned no embeddings; check model name and API key"); Prevention
- Confirm the embedding model id against Mistral's current model list
- Assert result count matches input count after each call
- Add an HTTP interceptor to capture empty response bodies
When it happens
Trigger: mistralAiApi.embeddings(apiRequest) succeeds through the retry template but embeddingResponseEntity.getBody() == null — empty body from the Mistral embeddings endpoint or deserialization failure yielding null.
Common situations: Embedding model name (e.g. 'mistral-embed') misspelled or unavailable on the account; API key/quota problems; proxy or gateway returning empty bodies; Mistral API schema changes after version upgrades.
Related errors
- No chat completion returned for prompt: + prompt
- No chat completion returned for prompt: + prompt
- No moderation response returned for request: + mistralAiMode
- HTTP %s - %s
- Required properties for TitanEmbeddingBedrockApi are missing
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/17a8fbc7890dc9cb.
Report an issue: GitHub.