Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(featherless_ai): use correct FEATHERLESS_AI_API_KEY env var name

giulio-leone7d21770d995f
diff --git a/litellm/llms/featherless_ai/chat/transformation.py b/litellm/llms/featherless_ai/chat/transformation.py
index 96702cf886e..e62108624d3 100644
--- a/litellm/llms/featherless_ai/chat/transformation.py
+++ b/litellm/llms/featherless_ai/chat/transformation.py
@@ -103,10 +103,15 @@ class FeatherlessAIConfig(OpenAIGPTConfig):
# FeatherlessAI is openai compatible, set to custom_openai and use FeatherlessAI's endpoint
api_base = (
api_base
+ or get_secret_str("FEATHERLESS_AI_API_BASE")
or get_secret_str("FEATHERLESS_API_BASE")
or "https://api.featherless.ai/v1"
)
- dynamic_api_key = api_key or get_secret_str("FEATHERLESS_API_KEY")
+ dynamic_api_key = (
+ api_key
+ or get_secret_str("FEATHERLESS_AI_API_KEY")
+ or get_secret_str("FEATHERLESS_API_KEY")
+ )
return api_base, dynamic_api_key
def validate_environment(
diff --git a/tests/test_litellm/llms/featherless_ai/chat/test_featherless_chat_transformation.py b/tests/test_litellm/llms/featherless_ai/chat/test_featherless_chat_transformation.py
index b4ef78b9137..666cfbd9488 100644
--- a/tests/test_litellm/llms/featherless_ai/chat/test_featherless_chat_transformation.py
+++ b/tests/test_litellm/llms/featherless_ai/chat/test_featherless_chat_transformation.py
@@ -149,6 +149,38 @@ class TestFeatherlessAIConfig:
)
assert "Featherless AI doesn't support tools=" in str(excinfo.value)
+ def test_get_provider_info_with_featherless_ai_api_key(self):
+ """Test that FEATHERLESS_AI_API_KEY env var is picked up correctly"""
+ config = FeatherlessAIConfig()
+ with patch.dict(os.environ, {"FEATHERLESS_AI_API_KEY": "key-from-ai-env"}, clear=False):
+ api_base, api_key = config._get_openai_compatible_provider_info(
+ api_base=None, api_key=None
+ )
+ assert api_key == "key-from-ai-env"
+ assert api_base == "https://api.featherless.ai/v1"
+
+ def test_get_provider_info_with_legacy_featherless_api_key(self):
+ """Test that legacy FEATHERLESS_API_KEY env var still works"""
+ config = FeatherlessAIConfig()
+ with patch.dict(os.environ, {"FEATHERLESS_API_KEY": "key-from-legacy-env"}, clear=False):
+ api_base, api_key = config._get_openai_compatible_provider_info(
+ api_base=None, api_key=None
+ )
+ assert api_key == "key-from-legacy-env"
+ assert api_base == "https://api.featherless.ai/v1"
+
+ def test_get_provider_info_prefers_featherless_ai_key_over_legacy(self):
+ """Test that FEATHERLESS_AI_API_KEY takes precedence over FEATHERLESS_API_KEY"""
+ config = FeatherlessAIConfig()
+ with patch.dict(os.environ, {
+ "FEATHERLESS_AI_API_KEY": "preferred-key",
+ "FEATHERLESS_API_KEY": "legacy-key",
+ }, clear=False):
+ _, api_key = config._get_openai_compatible_provider_info(
+ api_base=None, api_key=None
+ )
+ assert api_key == "preferred-key"
+
def test_default_api_base(self):
"""Test that default API base is used when none is provided"""
config = FeatherlessAIConfig()