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(fireworks_ai): map the Fireworks delete response body to DeleteResponseResult

mateo-berri217b5c404c42
diff --git a/litellm/llms/fireworks_ai/responses/transformation.py b/litellm/llms/fireworks_ai/responses/transformation.py
index f36030bb50a..7f29e03ff0f 100644
--- a/litellm/llms/fireworks_ai/responses/transformation.py
+++ b/litellm/llms/fireworks_ai/responses/transformation.py
@@ -1,6 +1,9 @@
from collections.abc import Mapping
from types import MappingProxyType
-from typing import Final
+from typing import TYPE_CHECKING, Final
+from urllib.parse import unquote
+
+import httpx
from litellm.llms.fireworks_ai.common_utils import (
resolve_fireworks_api_key,
@@ -10,9 +13,13 @@ from litellm.llms.fireworks_ai.common_utils import (
from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfig
from litellm.secret_managers.main import get_secret_str
from litellm.types.llms.openai import ResponseInputParam
+from litellm.types.responses.main import DeleteResponseResult
from litellm.types.router import GenericLiteLLMParams
from litellm.types.utils import LlmProviders
+if TYPE_CHECKING:
+ from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
+
FIREWORKS_AI_DEFAULT_API_BASE: Final = "https://api.fireworks.ai/inference/v1"
@@ -64,5 +71,13 @@ class FireworksAIResponsesAPIConfig(OpenAIResponsesAPIConfig):
headers=headers,
)
+ def transform_delete_response_api_response(
+ self,
+ raw_response: httpx.Response,
+ logging_obj: "LiteLLMLoggingObj",
+ ) -> DeleteResponseResult:
+ deleted_id: Final = unquote(raw_response.request.url.path.rsplit("/", 1)[-1])
+ return DeleteResponseResult(id=deleted_id, object="response", deleted=True)
+
def supports_native_websocket(self) -> bool:
return False
diff --git a/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py b/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
index 207fd518f89..997949bd03a 100644
--- a/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
+++ b/tests/test_litellm/llms/fireworks_ai/responses/test_fireworks_ai_responses_transformation.py
@@ -3,6 +3,7 @@ from collections.abc import Mapping
from types import MappingProxyType
from typing import Final, TypedDict
from unittest.mock import MagicMock, patch
+from urllib.parse import quote
import httpx
import pytest
@@ -261,3 +262,16 @@ def test_validate_environment_without_any_key_raises() -> None:
FireworksAIResponsesAPIConfig().validate_environment(
headers=NO_HEADERS, model="accounts/fireworks/models/kimi-k3", litellm_params=None
)
+
+
+def test_delete_responses_maps_fireworks_message_only_body_to_deleted_result() -> None:
+ response_id: Final = "resp_xFaIJR9Nc_OXmqKRqL78UuAGj2Te5GY5BT_knpZiMrYoNOVmu5oc2mQW1HI7hCtEYB4mcx2lEYS0DYP1U5yEQskHunuB4=="
+ request: Final = httpx.Request("DELETE", f"{FIREWORKS_RESPONSES_URL}/{quote(response_id, safe='')}")
+ client: Final = MagicMock()
+ client.delete.return_value = httpx.Response(200, json={"message": "Response deleted successfully"}, request=request)
+ with patch(HTTPX_CLIENT_FACTORY, return_value=client):
+ result: Final = litellm.delete_responses(
+ response_id=response_id, custom_llm_provider="fireworks_ai", api_key="fw-test-key"
+ )
+ assert client.delete.call_args.kwargs["url"] == str(request.url)
+ assert (result.id, result.object, result.deleted) == (response_id, "response", True)