{"record":{"id":"e0be9128eec99a6f","repo":"BerriAI/litellm","slug":"tinyfish-api-key-is-not-set-set-tinyfish-api-key","errorCode":null,"errorMessage":"TINYFISH_API_KEY is not set. Set `TINYFISH_API_KEY` environment variable.","messagePattern":"TINYFISH_API_KEY is not set\\. Set `TINYFISH_API_KEY` environment variable\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/tinyfish/search/transformation.py","lineNumber":67,"sourceCode":"    def get_http_method(self) -> Literal[\"GET\", \"POST\"]:\n        return \"GET\"\n\n    def validate_environment(\n        self,\n        headers: dict[str, str],\n        api_key: str | None = None,\n        api_base: str | None = None,\n        **kwargs: object,\n    ) -> dict[str, str]:\n        resolved_key: Final = self.resolve_server_api_key(\n            caller_api_key=api_key,\n            caller_api_base=api_base,\n            key_env_vars=(\"TINYFISH_API_KEY\",),\n            base_env_var=\"TINYFISH_API_BASE\",\n            default_api_base=self.TINYFISH_API_BASE,\n        )\n        if not resolved_key:\n            raise ValueError(\"TINYFISH_API_KEY is not set. Set `TINYFISH_API_KEY` environment variable.\")\n        return {**headers, \"X-API-Key\": resolved_key, \"Accept\": \"application/json\"}\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        optional_params: dict[str, object],\n        data: dict[str, object] | list[dict[str, object]] | None = None,\n        **kwargs: object,\n    ) -> str:\n        resolved_base: Final = api_base or get_secret_str(\"TINYFISH_API_BASE\") or self.TINYFISH_API_BASE\n        if isinstance(data, dict) and _TINYFISH_PARAMS_KEY in data:\n            validated_params: Final = _UrlEncodableParams.validate_python(data[_TINYFISH_PARAMS_KEY])\n            return f\"{resolved_base}?{urlencode(validated_params, doseq=True)}\"\n        return resolved_base\n\n    def transform_search_request(\n        self,\n        query: str | list[str],","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/tinyfish/search/transformation.py#L49-L85","documentation":"For Tinyfish web search, LiteLLM resolves the credential through resolve_server_api_key using the caller's api_key argument or the TINYFISH_API_KEY environment variable. If neither is present it raises this ValueError in validate_environment, before the search request is dispatched. The resolved key would be sent as the X-API-Key header.","triggerScenarios":"Invoking litellm.web_search(provider='tinyfish', ...) (or the equivalent proxy route) when TINYFISH_API_KEY is not set in the process environment and no api_key kwarg is supplied.","commonSituations":"Adding the Tinyfish provider to a gateway without provisioning its key; local development where the key is in a different shell's env; deploying to serverless (Lambda/Cloud Run) where env vars must be configured in the platform; renaming from another provider's key variable and missing the update.","solutions":["Set TINYFISH_API_KEY in the runtime environment of the litellm process.","Pass api_key explicitly on the web_search call or via proxy model_list litellm_params.","Check the variable is exported and non-empty in the exact process making the call.","Optionally set TINYFISH_API_BASE as well if you use a non-default Tinyfish endpoint."],"exampleFix":"# before\nresults = litellm.web_search(query=\"tinyfish llm search\", provider=\"tinyfish\")\n# -> ValueError: TINYFISH_API_KEY is not set...\n\n# after\nimport os\nresults = litellm.web_search(\n    query=\"tinyfish llm search\",\n    provider=\"tinyfish\",\n    api_key=os.environ[\"TINYFISH_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\n\ndef tinyfish_search_ready(api_key: str | None = None) -> bool:\n    return bool(api_key or os.environ.get(\"TINYFISH_API_KEY\"))\n\n\nif not tinyfish_search_ready():\n    raise RuntimeError(\"TINYFISH_API_KEY not configured — cannot use tinyfish provider\")","typeGuard":null,"tryCatchPattern":"try:\n    results = litellm.web_search(query=q, provider=\"tinyfish\")\nexcept ValueError as e:\n    if \"TINYFISH_API_KEY is not set\" in str(e):\n        results = litellm.web_search(query=q, provider=\"tavily\")  # fallback provider\n    else:\n        raise","preventionTips":["Maintain a provider->required-env-var map and verify it in CI.","When adding a niche search provider, provision its key in the same change that enables the code path.","Prefer passing api_key from your secret store over ambient env for auditability."],"tags":["tinyfish","web-search","api-key","environment-variables","litellm"],"backgroundTag":"missing-api-key","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}