{"record":{"id":"144401ff7595ca83","repo":"BerriAI/litellm","slug":"nimble-api-key-is-not-set-set-nimble-api-key-en","errorCode":null,"errorMessage":"NIMBLE_API_KEY is not set. Set `NIMBLE_API_KEY` environment variable.","messagePattern":"NIMBLE_API_KEY is not set\\. Set `NIMBLE_API_KEY` environment variable\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/nimble/search/transformation.py","lineNumber":110,"sourceCode":"        api_key: str | None = None,\n        api_base: str | None = None,\n        **kwargs: object,  # kwargs-ok: BaseSearchConfig.validate_environment signature\n    ) -> dict[str, str]:  # mutable-ok: the http handler passes this straight to httpx as headers\n        \"\"\"\n        Validate environment and return headers.\n\n        Returns a new dict rather than mutating ``headers``: the http handler calls this\n        a second time after ``litellm/search/main.py`` already did, so it has to be idempotent.\n        \"\"\"\n        resolved_api_key: Final = self.resolve_server_api_key(\n            caller_api_key=api_key,\n            caller_api_base=api_base,\n            key_env_vars=(\"NIMBLE_API_KEY\",),\n            base_env_var=\"NIMBLE_API_BASE\",\n            default_api_base=self.NIMBLE_API_BASE,\n        )\n        if not resolved_api_key:\n            raise ValueError(\"NIMBLE_API_KEY is not set. Set `NIMBLE_API_KEY` environment variable.\")\n        return {  # mutable-ok: httpx requires a plain dict of headers\n            **headers,\n            \"Authorization\": f\"Bearer {resolved_api_key}\",\n            \"Content-Type\": \"application/json\",\n            # Nimble's client-attribution header: names the calling software, nothing else.\n            \"X-Client-Source\": \"litellm\",\n        }\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        optional_params: dict[str, object],  # mutable-ok: BaseSearchConfig.get_complete_url signature\n        data: dict[str, object] | list[dict[str, object]] | None = None,  # mutable-ok: base signature\n        **kwargs: object,  # kwargs-ok: BaseSearchConfig.get_complete_url signature\n    ) -> str:\n        resolved_base: Final = (api_base or get_secret_str(\"NIMBLE_API_BASE\") or self.NIMBLE_API_BASE).rstrip(\"/\")\n        if resolved_base.endswith(\"/search\"):\n            return resolved_base","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/nimble/search/transformation.py#L92-L128","documentation":"Raised by litellm's Nimble web-search transformer when resolve_server_api_key cannot find a key: no api_key argument and no NIMBLE_API_KEY environment variable. It is raised while building request headers, before any HTTP call to Nimble's search API.","triggerScenarios":"Calling litellm.search() (or the /v1/search endpoint on the proxy) with engine='nimble' without an api_key param and without NIMBLE_API_KEY set in the environment.","commonSituations":"Forgetting the env var when switching a search job to Nimble, proxy deployment missing the secret, or assuming the generic search API key covers all engines.","solutions":["export NIMBLE_API_KEY=<key from nimble.com> in the environment running litellm.","Or pass api_key explicitly on the search call / in the proxy config for the nimble engine.","Restart the process after exporting so the env var is visible.","If overriding the endpoint, also set NIMBLE_API_BASE correctly."],"exampleFix":"# before\nresults = litellm.search(query=\"latest ai news\", engine=\"nimble\")\n\n# after\nresults = litellm.search(\n    query=\"latest ai news\",\n    engine=\"nimble\",\n    api_key=os.environ[\"NIMBLE_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\nif not os.getenv(\"NIMBLE_API_KEY\"):\n    raise RuntimeError(\"NIMBLE_API_KEY not set; required for engine='nimble'\")","typeGuard":null,"tryCatchPattern":"try:\n    results = litellm.search(query=q, engine=\"nimble\")\nexcept ValueError as e:\n    if \"NIMBLE_API_KEY is not set\" in str(e):\n        raise RuntimeError(\"Config error: NIMBLE_API_KEY missing\") from e\n    raise","preventionTips":["Map each search engine to its required env var in a config table.","Run a preflight secrets check before serving traffic.","Restart processes after exporting new env vars."],"tags":["nimble","web-search","api-key","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}