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]

test(fireworks_ai): inject spec'd HTTPHandler mock, drop test docstrings

Miles Adkins6b3977472b44
diff --git a/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py b/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py
index cc5b7880e9f..95a4902a1f2 100644
--- a/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py
+++ b/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py
@@ -1154,11 +1154,6 @@ def test_reasoning_effort_integer_passthrough():
def test_reasoning_effort_auto_dropped_to_model_default():
- """
- Fireworks rejects reasoning_effort="auto" (accepted set: low/medium/high/
- xhigh/max/none/adaptive). Omitting the param is the model default, which is
- exactly what "auto" means on OpenAI's side, so it must not reach the request.
- """
config = FireworksAIConfig()
result = config.map_openai_params(
{"reasoning_effort": "auto"},
@@ -1498,11 +1493,6 @@ def test_map_extra_body_params_guided_native_response_format_wins():
def test_map_extra_body_params_top_level_response_format_beats_nested():
- """
- With response_format set both top-level and inside extra_body, the http
- handler merges extra_body last, so the nested copy would silently clobber
- the explicit top-level one. The nested copy must be dropped instead.
- """
config = FireworksAIConfig()
result = config.map_extra_body_params(
{
@@ -1584,15 +1574,6 @@ def test_map_extra_body_params_no_extra_body():
def test_nim_vllm_extras_translated_end_to_end_in_request_body():
- """
- Passing NIM/vLLM extras to litellm.completion must reach the Fireworks
- request body translated, not verbatim: truncate_prompt_tokens becomes
- prompt_truncate_len, chat_template_kwargs.enable_thinking becomes
- reasoning_effort, include_reasoning is dropped, and min_tokens and
- fireworks-native top_k still pass through. Asserts on the actual JSON
- posted to the API, so a revert of the _complete_fireworks_ai wiring
- fails this test.
- """
from litellm.llms.custom_httpx.http_handler import HTTPHandler
model = "accounts/fireworks/models/glm-5p1"
@@ -1616,21 +1597,21 @@ def test_nim_vllm_extras_translated_end_to_end_in_request_body():
raw_response.text = json.dumps(body)
raw_response.json = lambda: body
- client = HTTPHandler()
- with patch.object(client, "post", return_value=raw_response) as mock_post:
- litellm.completion(
- model=f"fireworks_ai/{model}",
- messages=[{"role": "user", "content": "hi"}],
- api_key="fw-test-key",
- client=client,
- truncate_prompt_tokens=4096,
- chat_template_kwargs={"enable_thinking": False},
- min_tokens=10,
- include_reasoning=False,
- top_k=40,
- )
-
- request_body = json.loads(mock_post.call_args.kwargs["data"])
+ client = MagicMock(spec=HTTPHandler)
+ client.post.return_value = raw_response
+ litellm.completion(
+ model=f"fireworks_ai/{model}",
+ messages=[{"role": "user", "content": "hi"}],
+ api_key="fw-test-key",
+ client=client,
+ truncate_prompt_tokens=4096,
+ chat_template_kwargs={"enable_thinking": False},
+ min_tokens=10,
+ include_reasoning=False,
+ top_k=40,
+ )
+
+ request_body = json.loads(client.post.call_args.kwargs["data"])
assert request_body["prompt_truncate_len"] == 4096
assert "truncate_prompt_tokens" not in request_body
assert request_body["reasoning_effort"] == "none"
@@ -1641,11 +1622,6 @@ def test_nim_vllm_extras_translated_end_to_end_in_request_body():
def test_in_schema_unsupported_params_still_raise():
- """
- The extras translation channel does not weaken the supported-params gate
- for in-schema OpenAI params: store is still rejected with drop_params=False
- and dropped with drop_params=True.
- """
with pytest.raises(litellm.UnsupportedParamsError):
litellm.get_optional_params(
model="accounts/fireworks/models/llama-v3-70b-instruct",
diff --git a/tests/test_litellm/llms/fireworks_ai/completion/test_fireworks_ai_text_completion_transformation.py b/tests/test_litellm/llms/fireworks_ai/completion/test_fireworks_ai_text_completion_transformation.py
index 51ccd5df715..5408c6dc520 100644
--- a/tests/test_litellm/llms/fireworks_ai/completion/test_fireworks_ai_text_completion_transformation.py
+++ b/tests/test_litellm/llms/fireworks_ai/completion/test_fireworks_ai_text_completion_transformation.py
@@ -29,11 +29,6 @@ _NON_REASONING_MODEL = "fireworks_ai/accounts/fireworks/models/llama-v3-70b-inst
def test_map_extra_body_params_strips_truncate_params():
- """
- prompt_truncate_len is accepted on chat completions but rejected by
- /v1/completions ("Extra inputs are not permitted"), so both the NIM/vLLM
- name and the Fireworks name must be stripped on the text completion path.
- """
config = FireworksAITextCompletionConfig()
result = config.map_extra_body_params(
{"extra_body": {"truncate_prompt_tokens": 4096, "prompt_truncate_len": 2048}},
@@ -79,10 +74,6 @@ def test_map_extra_body_params_chat_template_kwargs_dropped_for_non_reasoning_mo
def test_map_extra_body_params_top_level_reasoning_effort_moves_into_extra_body():
- """
- The OpenAI SDK completions.create() rejects a top-level reasoning_effort
- kwarg, so it must ride inside extra_body (and win over kwargs-derived effort).
- """
config = FireworksAITextCompletionConfig()
result = config.map_extra_body_params(
{
@@ -172,12 +163,6 @@ def test_map_extra_body_params_strips_unsupported_and_preserves_passthrough():
def test_transform_text_completion_request_keeps_sdk_rejected_keys_in_extra_body():
- """
- The request data is spread into the typed OpenAI SDK completions.create(),
- so anything the SDK does not accept (reasoning_effort, response_format,
- prompt_truncate_len, fireworks-native extras) must live inside extra_body
- or the call raises TypeError before it reaches Fireworks.
- """
config = FireworksAITextCompletionConfig()
data = config.transform_text_completion_request(
model="glm-5p1",