weaviate/weaviate · error
no api key found neither in request header: X-Mistral-Api-Ke
Error message
no api key found neither in request header: X-Mistral-Api-Key nor in environment variable under MISTRAL_APIKEY
What it means
The generative-mistral module resolves the Mistral API key in getApiKey() by checking the request context header X-Mistral-Api-Key, then the module-level key loaded from the MISTRAL_APIKEY environment variable at startup. If both are absent, Generate fails with this error and no inference request is made.
Source
Thrown at modules/generative-mistral/clients/mistral.go:201
return nil
}
func (v *mistral) getMistralUrl(ctx context.Context, baseURL string) (string, error) {
passedBaseURL, err := modulecomponents.ValidatedBaseURLFromHeader(ctx, "X-Mistral-Baseurl", baseURL)
if err != nil {
return "", err
}
return url.JoinPath(passedBaseURL, "/v1/chat/completions")
}
func (v *mistral) getApiKey(ctx context.Context) (string, error) {
if apiKey := modulecomponents.GetValueFromContext(ctx, "X-Mistral-Api-Key"); apiKey != "" {
return apiKey, nil
}
if v.apiKey != "" {
return v.apiKey, nil
}
return "", errors.New("no api key found " +
"neither in request header: X-Mistral-Api-Key " +
"nor in environment variable under MISTRAL_APIKEY")
}
type generateInput struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
}
type generateResponse struct {
Choices []Choice
Usage *usage `json:"usage,omitempty"`
Error *mistralApiError `json:"error,omitempty"`
}
View on GitHub (pinned to 75aa4b6d11)
Solutions
- Set MISTRAL_APIKEY in the server environment and restart Weaviate (e.g. docker-compose environment: MISTRAL_APIKEY=<key>).
- Pass the key per-request via the X-Mistral-Api-Key header in your client's request headers options.
- Verify the module is enabled (ENABLE_MODULES=generative-mistral) so the env var is read at startup.
- Check that the env var value is a valid non-empty Mistral API key.
Example fix
// before: server env
services:
weaviate:
environment:
ENABLE_MODULES: generative-mistral
// after
services:
weaviate:
environment:
ENABLE_MODULES: generative-mistral
MISTRAL_APIKEY: ${MISTRAL_APIKEY} Defensive patterns
Strategy: validation
Validate before calling
import os
assert os.environ.get('MISTRAL_APIKEY'), 'Set MISTRAL_APIKEY before starting Weaviate' Try / catch
try:
result = collection.generate(...)
except WeaviateError as e:
if 'no api key found' in str(e) and 'Mistral' in str(e):
configure_api_key_header('X-Mistral-Api-Key')
else:
raise Prevention
- Always set MISTRAL_APIKEY in server env (docker-compose/K8s secrets).
- Pass the provider header (X-Mistral-Api-Key) in client request headers for per-request keys.
- Keep module listed in ENABLE_MODULES.
- Health-check generation once after deployment to fail fast.
When it happens
Trigger: Calling a near_text/generative (Get{ ... _additional { generate } }) query on a class with generative-mistral configured, when no X-Mistral-Api-Key header is sent with the GraphQL request and the server was started without MISTRAL_APIKEY set (or without ENABLE_MODULES=generative-mistral picking it up).
Common situations: Running Weaviate in Docker/Kubernetes without passing -e MISTRAL_APIKEY; setting the key under a misspelled env var name; clients (e.g. Python/JS v4) not passing the header in the request options; key present but empty string.
Understand the failure class
Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.
Related errors
- no api key found neither in request header: X-Nvidia-Api-Key
- no api key found neither in request header: X-Anyscale-Api-K
- no api key found neither in request header: X-Cohere-Api-Key
- no api key found for Contextual AI neither in request header
- no api key found neither in request header: %s nor in enviro
AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04).
Data as JSON: /api/errors/c7d89776771f10f5.
Report an issue: GitHub.