{"record":{"id":"c7d89776771f10f5","repo":"weaviate/weaviate","slug":"no-api-key-found-neither-in-request-header-x-mist","errorCode":null,"errorMessage":"no api key found neither in request header: X-Mistral-Api-Key nor in environment variable under MISTRAL_APIKEY","messagePattern":"no api key found neither in request header: X-Mistral-Api-Key nor in environment variable under MISTRAL_APIKEY","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/generative-mistral/clients/mistral.go","lineNumber":201,"sourceCode":"\treturn nil\n}\n\nfunc (v *mistral) getMistralUrl(ctx context.Context, baseURL string) (string, error) {\n\tpassedBaseURL, err := modulecomponents.ValidatedBaseURLFromHeader(ctx, \"X-Mistral-Baseurl\", baseURL)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn url.JoinPath(passedBaseURL, \"/v1/chat/completions\")\n}\n\nfunc (v *mistral) getApiKey(ctx context.Context) (string, error) {\n\tif apiKey := modulecomponents.GetValueFromContext(ctx, \"X-Mistral-Api-Key\"); apiKey != \"\" {\n\t\treturn apiKey, nil\n\t}\n\tif v.apiKey != \"\" {\n\t\treturn v.apiKey, nil\n\t}\n\treturn \"\", errors.New(\"no api key found \" +\n\t\t\"neither in request header: X-Mistral-Api-Key \" +\n\t\t\"nor in environment variable under MISTRAL_APIKEY\")\n}\n\ntype generateInput struct {\n\tModel       string    `json:\"model\"`\n\tMessages    []Message `json:\"messages\"`\n\tTemperature *float64  `json:\"temperature,omitempty\"`\n\tTopP        *float64  `json:\"top_p,omitempty\"`\n\tMaxTokens   *int      `json:\"max_tokens,omitempty\"`\n}\n\ntype generateResponse struct {\n\tChoices []Choice\n\tUsage   *usage           `json:\"usage,omitempty\"`\n\tError   *mistralApiError `json:\"error,omitempty\"`\n}\n","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/generative-mistral/clients/mistral.go#L183-L219","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before: server env\nservices:\n  weaviate:\n    environment:\n      ENABLE_MODULES: generative-mistral\n// after\nservices:\n  weaviate:\n    environment:\n      ENABLE_MODULES: generative-mistral\n      MISTRAL_APIKEY: ${MISTRAL_APIKEY}","handlingStrategy":"validation","validationCode":"import os\nassert os.environ.get('MISTRAL_APIKEY'), 'Set MISTRAL_APIKEY before starting Weaviate'","typeGuard":null,"tryCatchPattern":"try:\n    result = collection.generate(...)\nexcept WeaviateError as e:\n    if 'no api key found' in str(e) and 'Mistral' in str(e):\n        configure_api_key_header('X-Mistral-Api-Key')\n    else:\n        raise","preventionTips":["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."],"tags":["api-key","authentication","configuration","environment-variable","generative-mistral"],"backgroundTag":"missing-api-key","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}